1

I use a STM32F103C8T6 as a transmitter and an Arduino Uno as a receiver.

I cannot receive the value I am interested in. I have changed delay durations after each send and also CE pulse. I sometimes get it worked on spec by playing with delay durations.

To exemplify, I add a 200ms delay after TX function is executed and receiver receives very well then I disconnect the receiver and then when I connect it again, it receives nothing but zero. Very similar situations occur when I play with CE pulse duration. I cannot get it worked neither with auto-ack nor simple rx-tx operation. I would like to mention that when I change roles (TX device is Arduino and RX device is STM) everything works perfectly.

I've checked STM32 by a logic analyzer to see whether the payload is filled properly or not and could not see any problem. After I fill the payload, I check FIFO_STATUS register and everything is fine. After I apply a pulse for a certain duration, I check STATUS register and can see that TX_DS bit is set.

I've discovered that just applying 10us pulse on CE may not be enough. It can take up to 500us. Then decided to set CE pin high until TX_DS bit is set, but this method also did not work.

void TX_Mode(uint8_t data2send)
{

Flush_TX();
CleanInterrupts();
SetPRIM(PRIM_TX); //set as transmitter

csn_low(); //CSN=0
HAL_SPI_Transmit(&hspi2, &COMD_W_TX_PAYLOAD, 1,150); //send command to write to payload
HAL_SPI_TransmitReceive(&hspi2, &data2send, &dummy, 1, 150); // fill the payload
while(HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY);
csn_high();



ChipEnable_high();
while( !(TXDS_Bit_Is_Set() )); //wait until payload is sent
ChipEnable_low();

}
Shlomo
  • 14,102
  • 3
  • 28
  • 43
PIC16F84A
  • 143
  • 7

0 Answers0