Greetings, im vusing a TM4C123GXL launchboard and i found a strange problem.
After executting the next code, i can make first 4 times,that is light the 4 leds, 1 at a time and then when it reaches to the last condition, it goes to 0, but doesnt execute, and stops the code. I already had this in the interruption and was still worse, only could make 3 times and then stalls the program.
I can't find a solution to this. This will be used to change between modes of functioning.
int count, auxchange;
// Total LIMITS
unsigned long highcurrent = 200;
unsigned long highspeed = 3700;
unsigned long limit, crement, newlimit;
unsigned long speedlimit = 3000, currentlimit = 150, reglimit = 7, cruiselimit = 100;
// INTERRUPTIONS DEFINED ON STARTUP
extern void IntGPIOD(void);
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
void
Init (void) {
ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0);
ROM_FPULazyStackingEnable();
ROM_FPUEnable();
}
void
InitConsole(void)
{
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTStdioConfig(0, 115200, 80000000);
}
void
InitButtonsIO (void){
ROM_GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_2 );
ROM_GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_2 ,GPIO_STRENGTH_4MA,GPIO_PIN_TYPE_STD_WPU);
GPIOIntDisable(GPIO_PORTD_BASE, GPIO_PIN_2);
ROM_GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_2 , GPIO_FALLING_EDGE);
GPIOIntClear(GPIO_PORTD_BASE, GPIO_PIN_2);
GPIOIntRegister(GPIO_PORTD_BASE,IntGPIOD);
GPIOIntEnable(GPIO_PORTD_BASE, GPIO_PIN_2);
// ACTIVATE INTERRUPTS
IntMasterEnable();
// HISTERESIS PORT F3
GPIOIntDisable(GPIO_PORTF_BASE, GPIO_PIN_3);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3);
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_PIN_3);
// LEDS OUTPUTS
// Main Modes
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_6 | GPIO_PIN_7); // PD6 - Histeresis
GPIOIntEnable(GPIO_PORTD_BASE, GPIO_PIN_6 | GPIO_PIN_7); // PD7 - PWM
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_7 | GPIO_PIN_6 | GPIO_PIN_5); // PC7 - No control
GPIOIntEnable(GPIO_PORTC_BASE, GPIO_PIN_7 | GPIO_PIN_6 | GPIO_PIN_5); // PC6 - PI PC5 - PID
// Modes A/R
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_0); // PE0 - Current
GPIOIntEnable(GPIO_PORTE_BASE, GPIO_PIN_0);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_2); // PB0 - Regeneration current
GPIOIntEnable(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_2); // PB2 - Speed
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_1); // PD1 - Cruise control
GPIOIntEnable(GPIO_PORTD_BASE, GPIO_PIN_1);
}
int
main(void)
{
Init();
InitConsole();
InitButtonsIO();
while(1){
UARTprintf("\nAntes While, %d\n", auxchange);
if (auxchange == 0){
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_0, 0);
GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1 | GPIO_PIN_1, 0);
GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_0 , GPIO_PIN_0);
crement=10;
limit = currentlimit;
}
if (auxchange == 1){
GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_0, 0);
GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1, 0);
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_2, 0);
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0 , GPIO_PIN_0);
crement=1;
limit = reglimit;
}
if (auxchange == 2){
GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_0, 0);
GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1, 0);
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0, 0);
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_2 , GPIO_PIN_2);
crement=100;
limit = speedlimit;
}
if (auxchange == 3){
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_0, 0);
GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_0, 0);
GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1 , GPIO_PIN_1);
crement=100;
limit = cruiselimit;
}
if (auxchange >3){
auxchange=0;
}
SysCtlDelay(1000000);
}
}
//*****************************************************************************
void
IntGPIOD(void)
{
GPIOIntClear(GPIO_PORTD_BASE, GPIO_PIN_2);
auxchange=auxchange++;
}