cancel
Showing results for 
Search instead for 
Did you mean: 

issue with NRF24L01 on STM32F07VET6 blackboard

voxe
Associate

I've been trying to interface the STM32F407VET6 with the NRF24L01 modules, however after trying multiple boards modules and library's it still fails to work. im not sure the issue is with hardware as ive tried multiple modules and the black board has a slot designed for this type of module, moving the spi1 pins to SCK(PB3), MISO(PB4), MOSI(PB5) and CE(PB6) CS(PB7) IRQ(PB8), according to the schematics. Trying over the regular pins makes no difference either. 

 

The two main library's i tried were found on github. i tried following the controllerstech tutorial for writing the library and tried the one on github but neither worked using. for the controllerstech lib i tried transmitting to a dummy address which kept returning 0.

.https://github.com/controllerstech/NRF24L01.git 

the baud rate for the spi is 2mbps and all configs were kept the same

 

 

int main(void)

{

 HAL_Init();

 SystemClock_Config();

 MX_GPIO_Init();

 MX_SPI1_Init();

 MX_USART1_UART_Init();

/* USER CODE BEGIN 2 */

 NRF24_Init();

 NRF24_TxMode(TxAdress, 10);
 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6, 1);

 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7, 1);

/* USER CODE END 2 */

/* Infinite loop */

/* USER CODE BEGIN WHILE */
while (1)
 {
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */

char str[30];

int ret = NRF24_Transmit(TxData);

uint8_t NRF24_Transmit (uint8_t *data)

{

uint8_t cmdtosend = 0;

// select the device

 CS_Select();

// payload command

 cmdtosend = W_TX_PAYLOAD;

 HAL_SPI_Transmit(NRF24_SPI, &cmdtosend, 1, 100);

// send the payload

 HAL_SPI_Transmit(NRF24_SPI, data, 32, 1000);

// Unselect the device

 CS_UnSelect();

 HAL_Delay(1);

uint8_t fifostatus = nrf24_ReadReg(FIFO_STATUS);
// check the fourth bit of FIFO_STATUS to know if the TX fifo is empty

if ((fifostatus&(1<<4)) && (!(fifostatus&(1<<3))))

 {
 cmdtosend = FLUSH_TX;
 nrfsendCmd(cmdtosend);
// reset FIFO_STATUS
 nrf24_reset (FIFO_STATUS);
return 1;

 }
return 0;
}

 

 

 

the second library has a check function to test communication with the module however

this returned 0 which means that communication failed. i has to add two headers 1 support.h which has the spi

function for the nrf module however i always receive hal_ok from this even if the module is not connected.

https://github.com/elmot/nrf24l01-lib.git 

 

 

  nRF24_Init();

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
	  uint8_t ret = nRF24_Check();
	  char str[30];
	  sprintf(str,"returned %d ?? \r\n",ret);
	  HAL_UART_Transmit(&huart1, (uint8_t*)ass, strlen(ass), 1000);
	  HAL_Delay(1000);

    /* USER CODE BEGIN 3 */
  }

static void MX_SPI1_Init(void)
{

  /* USER CODE BEGIN SPI1_Init 0 */

  /* USER CODE END SPI1_Init 0 */

  /* USER CODE BEGIN SPI1_Init 1 */

  /* USER CODE END SPI1_Init 1 */
  /* SPI1 parameter configuration*/
  hspi1.Instance = SPI1;
  hspi1.Init.Mode = SPI_MODE_MASTER;
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
  hspi1.Init.NSS = SPI_NSS_SOFT;
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi1.Init.CRCPolynomial = 10;
  if (HAL_SPI_Init(&hspi1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN SPI1_Init 2 */

  /* USER CODE END SPI1_Init 2 */

}

 

 

 

i dont believe the issue is hardware but im not sure at this point any help is greatly appreciated or any information about alternative.

transceiver with similar functionality.

 

0 REPLIES 0