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.
Tool/software: Linux
I am compiling the following code segment for MSP430G2553 and MSP430FR2422:
__attribute((interrupt)) void i2c_recv_data_0(){ cmd_buffer[0] = UCB0RXBUF; i2c_irq = i2c_recv_data_1; }
Compiling for the G2553 I get the following assembler:
/opt/ti/msp430-6.1.0.0/bin/msp430-elf-gcc -M -mmcu=msp430g2553 -std=gnu11 -g -Os -Wall -pedantic -Wunused -ffunction-sections -fdata-sections -minrt -fomit-frame-pointer -fwrapv -MMD
f73c: d2 42 6e 00 mov.b &0x006e,&0x022a ;0x006e
Compiling for the FR2422 I get the following:
/opt/ti/msp430-6.1.0.0/bin/msp430-elf-gcc -M -mmcu=msp430fr2422 -msmall -std=gnu11 -g -Os -Wall -pedantic -Wunused -ffunction-sections -fdata-sections -minrt -fomit-frame-pointer -fwrapv -MMD
f672: 0c 15 pushm #1, r12 ;16-bit words f674: 1c 42 4c 05 mov &0x054c,r12 ;0x054c f678: c2 4c 3b 20 mov.b r12, &0x203b ... f682: 0c 17 popm #1, r12 ;16-bit words
As you can see, the code for the FR2422 entails an extra register transfer that bloats my code size.
I would expect to see similar output as the G2553 case.
Why is there an extra register usage???
I noticed that a word move was used to read the RXBUF while a byte move was used to store the data into your array. I checked the header file and sure enough, UCB0RXBUF is defined as a byte register on the G2553 while it is a word register on the fr2422. The symbol UCB0RXBUF_L gives you byte access and will shrink your code size.
Thank you very much, that was it!
Why would the TI sample code not use UCB0RXBUF_L and UCB0TXBUF_L??
**Attention** This is a public forum