This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

STM32F NRF24L01+ TX Problem


Hi.

I've been trying to send a payload with STM32F but I can not.
I've used both STM32F103 and STM32F3 to send a payload but neither of them worked.
However, when I use an Arduino Uno as a transmitter and STM32F as a receiver everything works perfectly.

I have tried 2 methods to send a payload so far but; I have not had any result.

1st method:

 void TX_Mode(uint8_t data2send)
{  
    SetPRIM(PRIM_TX); // set as tx

	csn_low(); //CSN=0
	HAL_SPI_Transmit(&hspi1, &COMD_W_TX_PAYLOAD, 1,150);
	HAL_SPI_TransmitReceive(&hspi1, &data2send, &dummy, 1, 150); // fill the payload
	while(HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);
	csn_high();
	
	ChipEnable_high(); //CE=1
    DWT_Delay_us(500); // wait for 500us
	Flush_TX(); //Flush TX FIFO
	CleanInterrupts(); //Clean all the interrupt flags
}


Note that, I confirmed that TX FIFO is filled and TX_DS Bit is set high by using 1st method.


2nd method:

void TX_Mode(uint8_t data2send)
{

    bool radio_busy = true;
	SetPRIM(PRIM_TX);

    // Fill the payload.
	csn_low(); //CSN=0
	HAL_SPI_Transmit(&hspi1, &COMD_W_TX_PAYLOAD, 1,150);
	HAL_SPI_TransmitReceive(&hspi1, &data2send, &dummy, 1, 150);
	while(HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);
	csn_high();
	
	ChipEnable_high();
	
	while(radio_busy)
	{
		
		if(TXDS_Bit_Is_Set()) // If the payload is sent
		{
			CleanInterrupts();
			ChipEnable_low(); // CE=0
			radio_busy = false;
		    break;
		}
		
		if(MAXRT_Bit_Is_Set()) // If Max Re-Transmission is reached
		{
			Flush_TX();
			CleanInterrupts();
			ChipEnable_low(); // CE=0
			radio_busy = false;
			break;
		}
		
	}

I haven't changed anything about TX_ADDR. I use the reset value 0xE7E7E7E7E7 as tx address.

Thanks in advance.

Parents Reply Children
No Data
Related