Hallo,
ich bin jetzt mal total ratlos.
Ich hab eigentlich nur ein total simplen test machen wollen aber da geht
nix. Folgender Code:
1 | #define DD_MOSI PINB5
|
2 | #define DD_MISO PINB6
|
3 | #define DD_SCK PINB7
|
4 |
|
5 | //overwrite PortB with SPI
|
6 | #define DDR_SPI DDRB
|
7 |
|
8 |
|
9 |
|
10 | void SPI_MasterInit(void) {
|
11 | // Set MOSI and SCKK output, all others input
|
12 | DDR_SPI = (1<<DD_MOSI)|(1<<DD_SCK);
|
13 |
|
14 | //Set SS as output (SS= PB4)
|
15 | DDRB|=(1<<PB4);
|
16 |
|
17 | //Enable SPI, Master, set clock rated fclk/16
|
18 | SPCR = (1<<SPE) | (1<<MSTR) | (1<<SPR0) |(1<<SPR1) ;
|
19 | }
|
20 |
|
21 | void SPI_MasterTransmit (char cData){
|
22 |
|
23 | //Start Transmission
|
24 | SPDR = cData;
|
25 |
|
26 | //wait for transmission complete
|
27 | while (!(SPSR & (1<<SPIF)));
|
28 | }
|
29 |
|
30 | int main(){
|
31 |
|
32 | SPI_MasterInit();
|
33 | SPI_MasterTransmit (0xAA);
|
34 | }
|
jetzt muesste ich ja zumindest ein signal am SCK sehen nachdem ich reset
gedrueckt hab. aber es passiert nichts. muss ich irgendwelche fuses
setzen oder hab ich irgendwas vergessen??
gruss
Patrick