Hello!
I have disabled RSTPE with SOPT1 = 0, but PTA5 GPIO still reset the microcontroller when it was to low level.
Please, Can anyone please help me to understand this behaviour?
This is my source code to set it:
void main(void)
{
//*******************************************************************
asm
{
ldhx #$83F;#__SEG_END_SSTACK ;
txs;
} // Inicializa Stack Pointer.
//*******************************************************************
// Inicializa Valores na RAM.
//
asm
{
ldhx #$40
res:
//sta SRS
clr ,x
aix #1
cphx #$0800
bcs res
nop
}
//*******************************************************************
// Configura periféricos.
/* WDOG_CNT: CNT=0xC520 */
WDOG_CNT = 0xC520U; /* First part of the WDG unlock sequence */
/* WDOG_CNT: CNT=0xD928 */
WDOG_CNT = 0xD928U; /* Second part of the WDG unlock sequence */
/* WDOG_TOVAL: TOVAL=4 */
WDOG_TOVAL = 0x04U;
/* WDOG_CS2: WIN=0,FLG=0,??=0,PRES=0,??=0,??=0,CLK=1 */
WDOG_CS2 = 0x11U;
/* WDOG_CS1: EN=0,INT=0,UPDATE=0,TST=0,DBG=0,WAIT=0,STOP=0 */
WDOG_CS1 = 0x81U; /* Disable watchdog */
PORT_PTAOE=0b00001100; // Seleciona Saídas PortA
PORT_PTBOE=0b00010010; // Seleciona Saídas PortB
PORT_PTCOE=0b00001111; // Seleciona Saídas PortC
PORT_PTDOE=0b00000000; // Seleciona Saídas PortD
PORT_PTAIE=0b00100010; // Seleciona Entradas PortA
PORT_PTBIE=0b11000101; // Seleciona Entradas PortB
PORT_PTCIE=0b01000000; // Seleciona Entradas PortC
PORT_PTDIE=0b00000000; // Seleciona Entradas PortD
PORT_PTAPE=0b00100000; // Pullup PortA
PORT_PTBPE=0b11000101; // Pullup PortB
PORT_PTCPE=0b00000000; // Pullup PortC
PORT_PTDPE=0b01000000; // Pullup PortD
//*******************************************************************
ICS_C2=0x00; //
ICS_C1=0x04; //
ICS_C3 = *(char*)0xFF6FU; /* Initialize ICS_C3 register from a non volatile memory */
ICS_C4 = (char)((*(char*)0xFF6EU)&(char)0x01U); /* Initialize ICS_C4 register from a non volatile memory */
//*******************************************************************
// Habilita Clocks dos periféricos.
//
SCG_C1=0b10100010;
//*******************************************************************
// Configura MTIM para Gerar interrupção periódica
//
MTIM0_MOD = 0;
MTIM0_CLK = 0b00000110; //
MTIM0_SC = 0b01000000; //
//*******************************************************************
// Acerta a multiplexação dos pinos aos periféricos.
//
SYS_SOPT1 = 0b10001100; // RSTPE=0
SYS_SOPT3 = 0b01000000; //
//*******************************************************************
//FTM0_C0SC = 0b00111000; // FTM0 como contador de tempo para
FTM0_SC = 0b00001011; // recepção de RF.
FTM0_MOD = 0; //
//*******************************************************************
// Configura FTM2 como PWM para os Led´s.
//
FTM2_C0SC = 0b00111000; // PWM Led
FTM2_C1SC = 0b00111000; // PWM Led
FTM2_C2SC = 0b00111000; // PWM Led
FTM2_SC = 0b01001011; //
FTM2_MOD = 1000; // Contagem Máxima do Timer.
FTM2_C0V = 0; // Ciclo ativo Led
FTM2_C1V = 0; // Ciclo ativo Led
FTM2_C2V = 0; // Ciclo ativo Led
//*******************************************************************
// Configura Conversor A/D.
//
ADC_APCTL2 = 0b00000000; //
ADC_APCTL1 = 0b10000000; // Entradas analógicas
ADC_SC3 = 0b01111001; //
ADC_SC2 = 0b00000000; //
ADC_SC1 = 0b00100111; //
NVM_FCLKDIV = 0x07;
DisableInterrupts;
__RESET_WATCHDOG(); /* feeds the dog */
EnableInterrupts;