When executing the simple program shown below for some reason after the first spi command is executed all of the following spi commands executed shift only 7 bits. Then when the next spi command is executed the final bit (0) gets shifted for the prior spi command and bits 7-1 are shifted for new spi command. I am using Codevision V3.42. I am using the Codevision supplied spi routine so i have to assume that is well tested.
I have been using Bascom and am new to C (and Codevision) so I assume I am overlooking something pretty basic. Is there some setting in Proteus or Codevision compiler settings that i am missing??
volatile unsigned char num1 = 20;
volatile unsigned char num2 = 40;
void main(void) {
// SPI initialization, SPI Type: Master, SPI Clock Rate: 4000.000 kHz, SPI Clock Phase: Cycle Start, SPI Clock Polarity: Low, SPI Data Order: MSB First
SPCR=(0<<SPIE) | (1<<SPE) | (0<<DORD) | (1<<MSTR) | (0<<CPOL) | (0<<CPHA) | (0<<SPR1) | (0<<SPR0); SPSR=(0<<SPI2X);
do {
num1++;
num2++;
spi(num1);
spi(num2);
}
while (num1<255);
}
FYI - I have tried var = spi(num1) also to see if that made a difference
Thanks
Blake
SPI - only 7 bits transferred after first SPI command
SPI - only 7 bits transferred after first SPI command
- Attachments
-
- CV_AVR SPI Prob.zip
- (44.48 KiB) Downloaded 677 times