2015-10-12 07:33 AM
Hello
I'm trying to send a 16 bit number with the SPI peripheral on a STM32F030 with the new HAL libary. Sending an 8 bit value is very easy but with a 16 bit number I receive errors or the hardware is crashing with a hardfault error.void
Rfm69_Write_Reg(uint8_t address, uint8_t value)
{
reg[0] = value;
reg[1] = address | 0x80;
HAL_SPI_Transmit(&hspi1, (uint8_t *)reg, 1, 1000);
}
This is the function i'm trying to implement now. But I always get a hardfault error when this function is executed. I do set the STM32 hardware for 16 bit using the CUBEMX software
2015-10-12 09:20 AM
So how and where is reg defined, and why not send TWO bytes instead of one?
Is the SPI in 8-bit mode or 16-bit mode, what code is generated by Cube to initialize the peripheral. What does the system tell you in the Hard Fault Handler? If it's just a while(1) loop, consider something that better decomposes the state of the system, and what memory address exactly it's faulting on.2016-10-05 03:58 PM
I'm sending two bytes together but it doesn't work. SPI is set with SPI_DATASIZE_8BIT.
uint8_t address[2] = {0xFB, 0xD8}; HAL_SPI_Transmit(&hspi1, &address, 2, 100); it says the argument 2 of HAL_SPI_Transmit is from incompatible pointer type..how come?2016-10-06 01:24 AM
because 'address' is already a pointer, so, either write it like this
HAL_SPI_Transmit(&hspi1, &address[0], 2, 100); or like this HAL_SPI_Transmit(&hspi1, address, 2, 100);