Hallo Zusammen, hab nach dem Problem das ich habe schonmal im Forum geschaut, aber nix passendes gefunden. Wie kann ich eíne uint32_t variable über die Hardware SPI übertragen? Das SPDR ist ja bloß ein Byte groß. Die uint32_t Variable soll in 4 in Reihe geschaltene Schieberegister (74HC595) geschoben werden.Wie kann ich die zerteilen ohne das ein Byte verloren geht? Den Quellcode habe ich aus dem Datenblatt!
1 | void SPI_MasterInit(void) |
2 | {
|
3 | /* Set MOSI and SCK output, all others input */
|
4 | DDR_SPI = (1<<DD_MOSI)|(1<<DD_SCK)|(1<<DD_RCK)|(1<<DD_inv_g); |
5 | /* Enable SPI, Master, set clock rate fck/16 */
|
6 | SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0); |
7 | }
|
8 | void SPI_MasterTransmit(char cData) |
9 | {
|
10 | /* Start transmission */
|
11 | PORTB|=(1<<DD_inv_g); //Output Disable |
12 | SPDR = cData; |
13 | /* Wait for transmission complete */
|
14 | while(!(SPSR & (1<<SPIF))) |
15 | PORTB|=(1<<DD_RCK); |
16 | PORTB&=~(1<<DD_inv_g); |
17 | |
18 | ;
|
19 | }
|