??? 06/17/09 02:20 Read: times |
#166166 - Slave Responding to: ???'s previous message |
Hi, thank you for the reply. I will have to try your suggestion to see if that has any effect.
Regarding the slave being interrupt driven, I'm new to SPI so I may be wrong but I think I'm dealing with a unique set of conditions here. The compass controls the clock line so it is clearly the master. However, the uC, as the slave, is actually requesting the SPI communication from the master/compass by pulling its CS pin low, not the other way around like one would expect in a normal master/slave SPI configuration. Let me summarize my code and the control scheme being used to see if you or anyone else sees something obviously wrong with the way I'm going about this. 1. I move the 'h' to the SPI Tx register so it is ready to send. According to the datasheet of my chip, this will sit in the buffer until it sees the proper transition on the CLK line when configured as a slave. 2. I pull the compass/master's CS line low to start SPI. This starts the SPI clock pulse from the compass (starts low). This is also when the compass sends the 's' to the uC/slave. Per item one above, the 'h' supposedly also gets sent out at this time. The clock line idles low... 3. When 8 bits are received via SPI, the SPI interrupt flag is set and the program enters the SPI interrupt. 4. In the interrupt, I clear the SPI Rx register by moving it to R0, clear the flag, and RETI 5. The compass/master will respond to the 'h' by sending two bytes of heading data, most significant byte first. The second byte is delayed by 50uS to allow the uC/slave time to process the first byte. 6. If the compass/master does not receive the 'h', it sends out an 'e' and stops all output on MOSI and CLK by setting them high. Currently, I am just dumping R0 out the UART so I can view it in HyperTerminal. Looking at the data I'm seeing, it's almost like everything is shifted over 2 bits because every 4 pulses, I can read the 's' and 'e' but what is causing the shift, I do not know. I also don't know why the compass is not receiving the proper 'h' command but my guess would be that the cause of the shifting on the incoming data is also shifting the data going out so it's not receiving the proper request. Per the compass/master's data sheet, I have the polarity and phase set correctly in the uC/slave but given the results I have had so far, I question my settings. I have verified with my scope that data is coming into the uC/slave on the MISO line and that the uC/slave is sending data out to the compass/master on the MISO line and that the CLK pulse is present. What am I missing here? It has to be something simple but I can't seem to put two and two together so any suggestions would be great. Thanks for reading, Brian |
Topic | Author | Date |
SiLabs C8051F500 and SPI | 01/01/70 00:00 | |
answered in crosspost at silabs forum | 01/01/70 00:00 | |
Please help? | 01/01/70 00:00 | |
it could be | 01/01/70 00:00 | |
Slave | 01/01/70 00:00 | |
Have you tried ... | 01/01/70 00:00 | |
thank you | 01/01/70 00:00 | |
Juat a thought | 01/01/70 00:00 | |
compass | 01/01/70 00:00 | |
update | 01/01/70 00:00 | |
just for fun/verification![]() | 01/01/70 00:00 |