MSP430X Port with IAR MSP430 Embedded Workbench v6.30.2

gregd29 wrote on Tuesday, June 30, 2015:

I just upgraded to the MSP430 IAR Embedded Workbench v6.30.2. I am getting some new compiler warnings that I am wondering about. Could anyone give me some feedback on whether they are potentially real problems that should be addressed.

Here are the warnings which occur at any reference to the portRESTORE_CONTEXT macro:

Warning[413]: A NOP needs to be added before setting GIE, as required by the architecture C:\FreeRTOSV8.2.1\FreeRTOS\Source\portable\IAR\MSP430X\portext.s43 133
Warning[411]: A NOP needs to be added after clearing GIE, as required by the architecture C:\FreeRTOSV8.2.1\FreeRTOS\Source\portable\IAR\MSP430X\portext.s43 133
Warning[410]: A NOP needs to be added after setting GIE if the next instruction clears GIE, as required by the architecture C:\FreeRTOSV8.2.1\FreeRTOS\Source\portable\IAR\MSP430X\portext.s43 133

If the portRESTORE_CONTEXT macro is updated with a NOP before and after the “pop.w sr” as shown below, the warnings will not be generated:

portRESTORE_CONTEXT macro

mov_x	&pxCurrentTCB, r12
mov_x	@r12, sp
pop_x	r15
mov.w	r15, &usCriticalNesting
popm_x	#12, r15
    nop        
pop.w	sr
    nop
reta
endm

There are also several other compiler warnings that have been generated in previous IAR compiler versions. Does anyone know of real problems that may be caused by these? Here are the warnings:

Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement C:\FreeRTOSV8.2.1\FreeRTOS\Source\tasks.c 3050
Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement C:\FreeRTOSV8.2.1\FreeRTOS\Source\tasks.c 3055
Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement C:\FreeRTOSV8.2.1\FreeRTOS\Source\tasks.c 3848
Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement C:\FreeRTOSV8.2.1\FreeRTOS\Source\tasks.c 3963
Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement C:\FreeRTOSV8.2.1\FreeRTOS\Source\tasks.c 3996
Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement C:\FreeRTOSV8.2.1\FreeRTOS\Source\tasks.c 4088

Thanks,
Greg Dunn

rtel wrote on Tuesday, June 30, 2015:

I think the nops have already been added to the main line code. Have a look at the following link and see if you think it is correct:
http://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Source/portable/IAR/MSP430X/portext.s43

Ref the Pa082 warnings - those warnings should be turned off in the port layer. The warnings are actually absolutely correct, however because of the code structure they bad thing the warning is warning about cannot actually happen. Unfortunately the warnings cannot be removed by updating the code because doing so generates warnings in more compilers than having the code as is does.

Regards.