You are here

Initializing the Port pins to a specific value in the Boot.tpl file | Cypress Semiconductor

Support & Community

Initializing the Port pins to a specific value in the Boot.tpl file

Last Updated: March 27, 2011

The code which runs prior to the execution of main( ) initializes the Port pins to a default value, which is LOW. How do I make the default state of the pin to be HIGH after reset?


This can be done by modifying the boot.tpl code.  

In the boot.tpl file, just before the call to LoadConfigInit, write a 1 to the corresponding bits of the Port data registers (PRTXDR). For example, to initialize P1[5] and P1[7] to a HIGH state after power up, add the following code in boot.tpl before the call to LoadConfigInit.

mov reg[PRT1DR], 0xA0

When the pin's drive mode gets configured in LoadConfigInit function, the pin state will change to HIGH.

Further, note that it is always advisable to add a comment in the beginning of main.c about the modification in boot.tpl.  This is because, in the future versions of the designer, the Boot.tpl file might be updated and if the user decides to upgrade to the new Boot.tpl file, then the modifications done to the Boot.tpl file will be lost

So, it is always advisable to have a record of the change in the main.c file. A solution for that is to keep the drive mode of the pin as High Impedance Analog in device editor view and in the application code area, assign a default state to the pin and then configure the drive mode.

Knowledge Base Tags: 

Provide feedback on this article

Browse KB By Product

Browse KB by Type