NRF24L01 enhanced shockburst

Hi guys,

So after getting my power supply problems sorted (another thread), I’m now having a problem with the enhanced shockburst features.

It works generally, but after a few minutes it seems to get stuck in a loop, with neither MAX_RT being set or TX_DS set (nor are any other interrupt flags set).

Here is the relevant section of code (about half way down is where it appears to get stuck):

NRF_TRANSMIT_ES
	;Load packet into TX FIFO using W_TX_PAYLOAD command
	BANKSEL	PORTB
	bcf		PORTB,CSN			;Set CSN low (activate device)
	
	BANKSEL	SSPBUF				;Bank0
	movlw	b'10100000'			;W_TX_PAYLOAD	(Enhanced shockburst ENABLED in EN_AA register)
	call	SPI_SEND			;Send command over SPI to device
	
	incf	PAYLOAD,F
	
	btfsc	STATUS,Z
	incf	PAYLOAD_COUNT,f
	
	movf	PAYLOAD_COUNT,w		;Load byte into payload	
	call	SPI_SEND	
	
	movf	PAYLOAD,w			;Load second byte into payload
	call	SPI_SEND
	
	movf	LOST_PACKET_COUNT,w	;Load third byte into payload
	call	SPI_SEND

	bsf		PORTB,CSN			;Set device to idle (CSN high)

	;Toggle CE for 10us minimum
	;-----------------------------
	BANKSEL	PORTB
	bsf		PORTB,CE		
		
	;Delay = (TIME+1)*4 except TIME=1 (9us), MAX TIME=127 (512us)
	movlw	d'4'	;delay 20us
	movwf	TIME
	call	DELAYus		
	
	bcf		PORTB,CE
	;-----------------------------
	
TX_WAIT	
	;Wait for transmission to complete or MAX_RT to be set, whichever comes first	
	BANKSEL	PORTA
	
	call	WAIT
		
	call	NRF_STATUS			;Read status register (result in CHAR)
	bsf		PORTA,BLUE_LED
	
	btfsc	CHAR,4				;If MAX_RT flag set
	goto	MAX_RT_SET									
						
	call	WAIT				        ;<---------------  Gets stuck in this loop (MAX_RT_SET not called)
	
	bcf		PORTA,BLUE_LED
	bcf		PORTA,RED_LED		

	call	NRF_STATUS	
	btfss	CHAR,5				;Check TX_DS flag
	goto	TX_WAIT				;If not set, wait again until set, or MAX_RT set	
	
	;Clear TX_DS Flag
	call	CLEAR_TX_DS

	goto	END_INTERRUPT
	
	

MAX_RT_SET
	;Called when MAX_RT flag is set
	;	- Maximum number of retransmits reached
	;	- No further transmissions will occur until this flag is reset
	BANKSEL	PORTA
	bsf		PORTA,RED_LED
	incf	LOST_PACKET_COUNT,F
	
	;FLush TX
	call	FLUSH_TX

	;Clear MAX_RT Flag
	movlw	b'00010000'			;write this to status register to clear MAX_RT flag
	movwf	DATA_BYTE
	
	movlw	STATUS_REG
	movwf	REG_ADDR
	
	call	NRF_W_REGISTER		;Write DATA_BYTE into REG_ADDR

	goto	END_INTERRUPT

Can anyone see any errors in the code that might cause this? I can’t see any other reason why MAX_RT or TX_DS wouldn’t get set.

Edit: Just want to make clear, I’m not saying MAX_RT_SET never gets called, I have received packets after the LOST_PACKET_COUNT has increased. But it just seems to get stuck in a loop while waiting for the flag to be set/transmission to complete sometimes.

Cheers

Kane

SIgh … I think I should just give up now … it was another power supply problem.

Adding a 1uf capacitor to the regulators fixed the issue.