I'm trying to communicate with a BNO055 using an STM32L552ZET6Q microcontroller via UART. The BNO055 is on a separate board, and connected to the STM32 via a 1.5M cable. Additionally, there are MAX3232CUE+T RS232 chips on either side of the cable, converting the UART data to RS232 and back again. This is to make sure communications aren't corrupted by EMI or simple distance while traveling through the cable.
When observing the data arriving from a logic analyzer, it looks different from what is displayed on the STM32 Debugger (seen below) Also keep in mind that these were both taken as UART (not RS232) in close proximity to the STM32.
Included below is the code used to write to and read from the BNO055 via UART:
void uartWrite(bno055_uart *chip, uint8_t reg, uint8_t len, uint8_t *buf)
{
uint8_t status;
uint8_t feedback[2];
uint8_t transmit_buf[128] = {0xAA, 0x00, reg, len};
for(uint8_t x = 0; x < len; x++)
{
transmit_buf[x + 4] = buf[x];
}
status = HAL_UART_Transmit(&chip->uart_bus, transmit_buf, (len + 4), 50);
//bno055_delay(10);
if(status == HAL_OK)
{
HAL_UART_Receive(&chip->uart_bus, feedback, 2, 50);
switch(feedback[1])
{
case 0x01:
return;
break;
case 0x03:
printf("Write Failure in BNO055 UART");
break;
case 0x04:
printf("Invalid Register map address");
break;
case 0x05:
printf("Register Map Write Disabled");
break;
case 0x06:
printf("Wrong Start Byte");
break;
case 0x07:
printf("Bus Over Run Error");
break;
case 0x08:
printf("Max Length Error");
break;
case 0x09:
printf("Min Length Error");
break;
case 0x0A:
printf("Receive Character Timeout");
break;
}
return;
}
else
{
printf("Error Occurred/r/n");
return;
}
}
void uartRead(bno055_uart *chip, uint8_t reg, uint8_t len, uint8_t *data)
{
uint8_t transmit_buf[128] = {0xAA, 0x01, reg, len};
HAL_UART_Transmit(&chip->uart_bus, transmit_buf, 4, 50);
//bno055_delay(10);
HAL_UART_Receive(&chip->uart_bus, data, (len+2), 50);
if(data[0] != 0xBB)
{
switch(data[1])
{
case 0x02:
printf("Read Failure");
break;
case 0x04:
printf("Register Map Invalid Address");
break;
case 0x05:
printf("Register Map Write Disabled");
break;
case 0x06:
printf("Wrong Start Byte");
break;
case 0x07:
printf("Bus over run error");
break;
case 0x08:
printf("Max length error");
break;
case 0x09:
printf("Min length error");
break;
case 0x0A:
printf("receive character timeout");
}
}
}
Edit 1: Below is a picture of the STM32 clock configuration in STM32CubeIDE. Both devices have external 32.768kHz clock sources attached to them.
Edit 2: I finally had a chance to try running the device with HAL_MAX_DELAY and it looks like the STM32 doesn't realize that anything has arrived on the bus. broken down, it shows the following:
a request is sent for the BNO055's id (0xA0). This command is composed of a start byte (0xAA), Read or Write (0x01 for read), What is being read (0x00) and how many bytes of data the BNO055 should send back (1, 0x01).
The response back from the BNO055 is success (0xBB), length of the data (0x01) and the data (0xA0).
However, the HAL_UART_RECEIVE function just keeps waiting for something to show up.
End of Edit 2
Below are links to the BNO055 datasheet, and BNO055 UART application notes respectively, as well as the datasheet for the MAX3232CUE+T: Link to BNO055 Datasheet Link to BNO055 UART application notes Link to MAX3232CUE+T Datasheet
I'm still collecting additional information, so if you have any specific questions, please let me know. Thank you for your assistance!