This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430FR5739: 20-bit function pointers

Part Number: MSP430FR5739


Tool/software: Code Composer Studio

Hello,

I ported the MSPBoot UART bootloader to the MSP430FR5739. The bootloader is using callback functions which are declared as void pointers.

typedef struct  {
    void (*RxCallback)(uint8_t);            // RX Flag callback
    void (*TxCallback)(uint8_t *);          // TX Flag callback
    void (*ErrorCallback)(uint8_t);         // Error callback
}t_CI_Callback;

When the code is compiled with the mspx, large code, large data flags, the compiler seems to think the callback pointers are 20-bit addresses and loads the wrong address.

Memory content:

0x001C04  FF56
0x001C06  RxPacket
0x001C06 001C 0000 0000 1C00 7CE6 7CE6 7CE6 7CE6 7CE6 00E6

The assembly instruction executed to fetch the callback function address is:

MOVA    &0x01c04,R15

What is loaded in the R15 register is 0x0CFF56 which is the 4 LSBs of 0x001C06 and the 16-bit callback pointer at 0x001C04.

Can I tell the compiler to use 20-bit callback pointers? or should I only use the small code flag when using function pointers?

Thank you!

Jocelyn Harvey

  • Hello Jocelyn,

    You should use small data models since the FR5739 FRAM space does not exceed 16-bit (all < 0xFFFF). What purpose would you have in using 20-bit callback pointers? Does your application intend to use shared callbacks?

    Regards,
    Ryan
  • I don't have any purpose in using 20-bit pointers so I will use small data models to make it work but I find it weird that pointers (ex: void* used for callback functions) are still 16-bits when the large memory model is selected. It can lead to function calls to undefined memory. Table 5-2 of the Compiler User's Guide mentions that when large data model is selected, data pointers are supposed to be 20 bits stored in 32..
  • I found the problem.. The callback pointer in the MSPBoot bootloader is forced at a specific location in the linker script file so the compiler doesn't know it's a pointer and should be stored as a 20-bit value.

    CI_Callback_ptr = 0x1C04;   /* Pointer to Comm callback structure */

    Thanks!

**Attention** This is a public forum