__IO what is

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

__IO what is

2,615 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Wed May 26 00:39:25 MST 2010
LPCXpresso with LPC1758
Sorry for my simply question, but I need to undestand the difference from

__IO uint32_t tx_head;

and

uint32_t tx_head

I have tested in ram and ther'isnt difference !!
0 Kudos
3 Replies

1,035 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by blasiis on Wed May 26 02:21:52 MST 2010

Quote: nerd62
Hi blasiis,

__IO is a preprocessor symbol which is defined to "volatile" (as rkiryanov wrote this). The "volatile" attribute tells the optimizer not to optimize too much. The content of the register may be changed by an other process from what the optimizer does not know about - so the content of the register has to be read everytime when there are made decisions which depend on the true content. When the optimizer does not know about the "volatile" attribute he may have the idea to copy the content of the IO-register into a general purpose register and make further decisions with the content of this general purpose register. This may work in one case - when you make small changes at your code it suddenly won't work. This leads e. g. to polling loops which suddenly don't terminate. I have spent a lot of time to debug such (homebrewed) errors in my last project.

Have much fun with your LPC, nerd62 ;-)


Therefor for  safety reasons it is best to put it in structure or similar
0 Kudos

1,035 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nerd62 on Wed May 26 01:23:37 MST 2010
Hi blasiis,

__IO is a preprocessor symbol which is defined to "volatile" (as rkiryanov wrote this). The "volatile" attribute tells the optimizer not to optimize too much. The content of the register may be changed by an other process from what the optimizer does not know about - so the content of the register has to be read everytime when there are made decisions which depend on the true content. When the optimizer does not know about the "volatile" attribute he may have the idea to copy the content of the IO-register into a general purpose register and make further decisions with the content of this general purpose register. This may work in one case - when you make small changes at your code it suddenly won't work. This leads e. g. to polling loops which suddenly don't terminate. I have spent a lot of time to debug such (homebrewed) errors in my last project.

Have much fun with your LPC, nerd62 ;-)
0 Kudos

1,035 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rkiryanov on Wed May 26 01:05:12 MST 2010

Quote: blasiis



__IO = volatile
__I = volatile const
0 Kudos