Hi everyone. I'm using the Tiva C workshop series on the focus.ti.com section of the website. The workshop series is designed for use with the TM4C123G device, however I'm using the Connected Dev Kit which has a TM4C129X.
So far I've been able to easily change the code to make it work on my device. Seeing as how they are both Tiva C series micros, I figured that all the API calls and such should be identical on both. However now I'm starting to think that something else needs to be adapted.
I'm working on Lab 4, which uses TIMER0 as an interrupt generator to flash the on-board LED. I followed the instructions perfectly (modifying the port and pin names/numbers to reflect my board) but when I upload the code to the board and execute, nothing happens. I've put a breakpoint at the beginning of the ISR and it never gets hit, so the interrupt isn't even being called.
Here is my code:
#include <stdint.h> #include <stdbool.h> #include "inc/tm4c129xnczad.h" #include "inc/hw_memmap.h" #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/gpio.h" #include "driverlib/timer.h" int main(void) { uint32_t ui32Period; SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_25MHZ|SYSCTL_OSC_MAIN); // setup up system clock at 60MHz? SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ|SYSCTL_PERIPH_GPION); // enable GPIO peripherals for Ports Q and N GPIOPinTypeGPIOOutput(GPIO_PORTQ_BASE, GPIO_PIN_4|GPIO_PIN_7); // set PINQ4 and PINQ7 as outputs GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_5); // set PINN5 as output SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); // enable TIMER0 peripheral TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); // configuer TIMER0 as a periodic timer ui32Period = (SysCtlClockGet() / 20) / 2; // set period variable to 10Hz TimerLoadSet(TIMER0_BASE, TIMER_A, ui32Period - 1); // load the period into TIMER0 IntEnable(INT_TIMER0A); // enable interrupts for TIMER0A TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // set the type of interrupt to timeout IntMasterEnable(); // enable master interrupts TimerEnable(TIMER0_BASE, TIMER_A); // enable timer0 while(1); } void Timer0IntHandler(void) { TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); if(GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_5)) { GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_4|GPIO_PIN_7, 0); GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5, 0); } else { GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5, 32); } }
This differs from the included Lab 4 code only in the GPIO lines. For the TM4C123G board, all three of the RGB LED pins are on the same port. For some reason on the Connected Dev Board, two are on Port Q and one on Port N. So I have changed the code to reflect this. I am quite sure this is not causing the problem as all the labs up until now worked with my changes. I'm thinking the problem might be in the names used to configure and execute the timer, ie, TIMER0_BASE, INT_TIMER0A. I can't seem to find the information about this for my microcontroller. I know from my experience with Atmel microcontrollers and their datasheets that things like name changes across chips in the same family are detailed in the corresponding section of the datasheet. I've been trying to find any info in the datasheet, but seeing as how it's over 2000 pages long it seems a futile search. I've read the timers section, and the interrupts section to no avail.
Can anyone help me figure out why this isn't working? I really want to get to the bottom of this before I move forward.
Thanks very much!