SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By Hotte
#40034
Hi @all,

I´ve got a problem with my nrf-module.
When I try to read out a register I only get back the status register and then nothing.

I´ve not init the nrf module jet cause I first wanna test the communication via SPI. So I try to write to one register and after that i try to read it out but I only get back the status register in the first Byte and then nothing:


// write(0x01,0x3F) to read out the EN_AA
write(nrf24l01_R_REGISTER|nrf24l01_EN_AA,nrf24l01_EN_AA_DEFAULT_VAL,2);


Read-Operation:
CSN: ----_____________________________________________-------
Clk:______--_--_--_--_--_--_--_--_____--_--_--_--_--_--_--_--_____________
MOSI:------_________________---------__-------------------------------
MISO:______________------------____________________________________


The polarity and the phase should be ok and my SPI runs with 1MHz.
Controller:AT91SAM7S64

Did anyone have an idea to solve the probleme?

Thanks


Code: Select all
void write(u_int8 addr, u_int8 dat, u_int8 anz)
{
	u_int8 i=0;
	i=(anz);
	unsigned char x[i];
	x[0]=addr;
	x[1]=dat;
	SPI_send(x,i);
}

void SPI_send(u_int8 *daten, u_int8 anz)	// Send data (DMA)
{

 	while(!(pSPI->SPI_SR&0x00000020));				
	while(!(pSPI->SPI_SR&0x00000002));				Empty
	u_int8 x[65],i;
	while(!(pSPI->SPI_SR&0x00000200));		//SPIENS - SPI 
	for(i=0;i<anz;i++)
	{
		x[i]=daten[i];
	}
	pSPI->SPI_TPR=(u_int16)x;
	pSPI->SPI_TCR=anz;
	pSPI->SPI_TNCR=0;
	pSPI->SPI_PTCR=0x0100;
}
By n1ist
#40036
I'm not familiar with the ARM processors, but the declaration of x in write() is wrong. The compiler doesn't know what i is at compile time (or at best uses the initialized value of 0). Either declare x as a fixed-size buffer - in this case unsigned char x[2] would work - or allocate space for it on the fly with malloc.
By Hotte
#40038
Thanks for this hint... now i make a global array.:idea:

But i still have the same problem :cry:
By Hotte
#40360
I found the problem.

After a few tests i found out, that i have to configure my spi with falling edges. I don´t know why cause in Brennen´s tut he writes that the SCK should normally aktive by rising edges.
User avatar
By leon_heller
#40364
SCK going low to high works for me, as well.

Leon