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.

20bit function argument

Hi all,

is there any way to declare a 20 bit address function argument, so it can be used in small data model ?

I need to migrate from a mspgcc project where i can do it using uint20_t  typedef.

Regards,

Luigi

  • It is almost certainly true that you are using a MSP430X device, and thus you should build with the switch --silicon_version=mspx.  Under those conditions, function pointers are 20-bits wide in both small and large memory models.  

    As for migrating the uint20_t typedef ... I cannot think of a general foolproof way to do it.  You could redefine it to be a function pointer ..

     typedef void (* uint20_t)(void);

    The problem is this restricts that type more than you would like.  This is only for pointers that take no arguments and return no result.  But perhaps you use uint20_t in only a few places, and this approach might be practical.

    Thanks and regards,

    -George

  • Hi George,
    thanks for your reply.

    All your assumptions are correct.
    The problem is that compiler adjusts the address value to 16-bit.

    A function prototype like this
    extern void crc16addr20(register uint16_t *crc, register uint16_t crcseed, register uint20_t src, register uint16_t size);

    should accept as src parameter something like:

    uint20_t __far_mem = (uint20_t) 0x10000;

    but compiler sets __far_mem to NULL.

    Actually the only solution i found is to set typedef unsigned long uint20_t; adapting the backend function to convert the 32-bit address to 20-bit.
    My app doesn't need large model, but needs to occasionally store/read data on the far flash (used as storage).

    I think source directives like this could be a usefull addon to the TI compiler.
    Thanks again and regards,
    Luigi