Hi Guys, I haven't used my Xmega256D3 in a while and decided to write a comms program in assembler via SPID as the Master and another Xmega256D3 as the slave.
Every time I read the IF bit in SPID_STATUS it always reads 0 so my program halts at that point. Have I left something out in my code? Here is my init code.
LDI R16,16+32+128 ;MOSI, SS, SCK OUTPUT. MISO INPUT. STS PORTD_DIR,R16 LDI R17,64+16+128 ;ENABLE SPI D AS MASTER + ENABLE + X2 SPEED. STS SPID_CTRL,R17 LDI R17,0 ;SPI INTERRUPTS OFF STS SPID_INTCTRL,R17 SPID_STATUS_READY: LDS R16,SPID_STATUS ;CHECK IF SPID IS READY. SBRS R16,7 RJMP SPID_STATUS_READY LDI R16,255 STS PORTE_DIR,R16 LOOP1: LDI R16,POWER_LED ;FLASH A LED ON PORTE0 STS PORTE_OUTSET,R16 RCALL DELAY_LONG LDI R16,POWER_LED STS PORTE_OUTCLR,R16 RCALL DELAY_LONG RJMP LOOP1
The program just waits for the IF bit in the STATUS register to be set but it looks like the bit is always clear and I have no idea why.
Have I left out something in the SPI INIT register? Any help here would be muchly appreciated.
Thanks guys for your help.