0
\$\begingroup\$

I'm trying to read some registers of an Atmel AT86RF233 transceiver via SPI with a Nucleo F446RE development board. As stated on the title, whenever I send anything through MOSI, the transceiver doesn't respond, even if the message is formatted with the exact same way specified at the datasheet. The transceiver isn't fried (tested it on an Arduino and it worked perfectly), I've used a logic analyzer (which displayed the signal on MOSI correctly but no MISO input) and as such I've come to the conclusion that there must be a problem with SPI. Any ideas?

Register reading code:

uint8_t AT86RF2XX::reg_read(const uint8_t addr)
{
    uint8_t value;
    uint8_t readCommand = addr | AT86RF2XX_ACCESS_REG | AT86RF2XX_ACCESS_READ;  //never mind for these constants, they're correct
    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET); 
// PA8 is set as GPIO output from CubemMX, and plays the role of the SS pin, now it goes off to wake up the slave

    HAL_SPI_TransmitReceive(spi, &readCommand, &value, 1, 100);
    while(HAL_SPI_GetState(spi) != HAL_SPI_STATE_READY);

    HAL_SPI_TransmitReceive(spi, &readCommand, &value, 1, 100);
    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);  // set it back to high to terminate the communication.

    return (uint8_t)value;
}

Thanks in advance.

\$\endgroup\$
4
  • \$\begingroup\$ Look at the actual spi signals with a scope or USB based logic analyzer. Make sure the pins are correctly configured. \$\endgroup\$ Dec 13 '18 at 16:43
  • \$\begingroup\$ Tried that, sorry for not mentioning it. I can see the signal to be sent on the MOSI line, but no input from MISO. I notice though that there are only 8 clock cycles instead of 16, so could this be something? Also, something I've observed just now: PA8 (SS) doesn't always go low and then high. \$\endgroup\$ Dec 13 '18 at 16:45
  • \$\begingroup\$ Never mind actually about A8, I forgot to reset the MCU, it's working correctly. The problem with SPI stll stands, of course. \$\endgroup\$ Dec 13 '18 at 16:54
  • \$\begingroup\$ Increasing timeout may help. \$\endgroup\$
    – Rokta
    Dec 14 '18 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.