In many examples we can use for example a #Define Pin_to_Use PIN_D1.
This is used when compiler generate the code.
However I have seen an example of change the PIN in runtime like this:
Code:
int16 pin_to_use;
pin_to_use=PIN_B0;
output_low(pin_to_use);
pin_to_use=PIN_B1;
output_low(pin_to_use);
But this does not work in my case so I wonder what can go wrong with this type of code in CCS ? It compiles OK but the I/O address is wrong not point to the address defined in header file for the MCU.
Are there other ways to alter the PIN in an output_high(PIN_xx) at runtime maybe ?
I use compiler 5.076 and MCU is a 30F5011.
PeWa
Joined: 15 Jan 2019 Posts: 22 Location: Sweden
Re: Change PIN at Runtime
Posted: Sat Nov 27, 2021 8:43 am
PeWa wrote:
In many examples we can use for example a #Define Pin_to_Use PIN_D1.
This is used when compiler generate the code.
However I have seen an example of change the PIN in runtime like this:
Code:
int16 pin_to_use;
pin_to_use=PIN_B0;
output_low(pin_to_use);
pin_to_use=PIN_B1;
output_low(pin_to_use);
But this does not work in my case so I wonder what can go wrong with this type of code in CCS ? It compiles OK but the I/O address is wrong not point to the address defined in header file for the MCU.
Are there other ways to alter the PIN in an output_high(PIN_xx) at runtime maybe ?
I use compiler 5.076 and MCU is a 30F5011.
Edited, the variable address is OK. I can change a static LED but it seems that when I change to variable the output / input functions take some more time to compute. Is that the case ??
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
Posted: Fri Dec 03, 2021 2:29 am
You can also use the get_env for the PORT and LAT register addresses.
Then build a struct as you like with a default set of values.
Then just write those values to PORT/LAT registers on start up.
You end up configuring an entire register with a single write.
I'd have to go look at an old example to see how much ASM results.... but it should be pretty thin. _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum