Good afternoon everyone, i am looking for a little help on what must be a pretty basic issue.
I am running the CAN PAL sample project and can send a receive messages but when i try to modify the main.c to package the data from an array using a for loop, it flashes to the device successfully but when i hit debug, i get the below in the console and the debug stops automatically.
UsageFault:An Unaligned access error has occurred
HardFault: A fault has been escalated to a hard fault
All i have added is a manual method for packaging data bytes into the transmit buffer but im having to do it in 8 separate commands, ive added a simple for loop but that kills the program. Im very used to using the Arduino IDE and this is my attempt to move forward with a more professional platform so any help would be great
Thanks
Rich
(*(uint32_t *)&CAN_TX_Buffer.id = 0x600);// sets the CAN ID to transmit
unsigned char data2[8] = {7, 6, 5, 4, 3, 2, 1, 0};// Sets the data to send into a character array
for(int t=0; t<7; t++){
(*(uint64_t *)&CAN_TX_Buffer.data[t] = data2[t]);/* increase the data, [2] is the byte of data in the 8 byte message to update */
//(*(uint64_t *)&CAN_TX_Buffer.data[0] = data2[0]);/* increase the data, [2] is the byte of data in the 8 byte message to update */
//(*(uint64_t *)&CAN_TX_Buffer.data[1] = data2[1]);/* increase the data, [2] is the byte of data in the 8 byte message to update */
//(*(uint64_t *)&CAN_TX_Buffer.data[2] = data2[2]);/* increase the data, [2] is the byte of data in the 8 byte message to update */
//(*(uint64_t *)&CAN_TX_Buffer.data[3] = data2[3]);/* increase the data, [2] is the byte of data in the 8 byte message to update */
//(*(uint64_t *)&CAN_TX_Buffer.data[4] = data2[4]);/* increase the data, [2] is the byte of data in the 8 byte message to update */
//(*(uint64_t *)&CAN_TX_Buffer.data[5] = data2[5]);/* increase the data, [2] is the byte of data in the 8 byte message to update */
//(*(uint64_t *)&CAN_TX_Buffer.data[6] = data2[6]);/* increase the data, [2] is the byte of data in the 8 byte message to update */
//(*(uint64_t *)&CAN_TX_Buffer.data[7] = data2[7]);/* increase the data, [2] is the byte of data in the 8 byte message to update */
}
CAN_Send(&can_pal1_instance, TX_MB, &CAN_TX_Buffer);// Sends the CAN message using non blocking type