PSoC® 1 PLC - PLT_Start and PLT_Restart Functions Affect Port1 and Port2 Data Registers - KBA216061

Version: **

 

Question:

Calling the PLT_Start or PLT_Restart functions overwrite the pins in Port1 and Port2 to their initial values configured in the PSoC Designer™ chip design window, even though these pins may not be used for any PLT-related function. Why does this occur and how to overcome this issue?

 

Answer:

This issue occurs because the PLT user module APIs “PLT_Start” and “PLT_Restart” make use of shadow registers to initialize Port1 and Port2 data registers.

To overcome this issue, the corresponding port shadow registers must be updated before making any change to the Port1 or Port 2 data registers. 

Example:

The following code snippet demonstrates how P1[7]'s value must be changed in the code of a project that has PLT code: 

void main()
{
    // Initialize Port1 Shadow register at beginning of code to the settings made in chip design window
    Port_1_Data_SHADE = 0x80; // Do this if the Initial value for P1[7] is 1, and other Port1 pins are 0 in chip     design window
    .
    .
    // When you want to clear P1[7], do the following:
    Port_1_Data_SHADE &= ~0x80; // Clear Bit 7 of Port1 Shadow register
    PRT1DR = Port_1_Data_SHADE; // Update Port1 Data register from Port1 Shadow register
    .
    .
    //Call PLT_Start() or PLT_Restart() function - This would not affect P1[7] since Port1 shadow register has     been updated
    PLT_Start();
    .
    .
}