Good day,
My code for configuring the NVIC and peripheral interrupts are already working as expected, but the only problem now is the debugger shows that the processor always jumps to the default handler (__default_handler) and never on my defined interrupt handler whenever I trigger the interrupt source.
I already added the specific interrupt vector in the vector table from the file vector_table_M.s and included it in my project. Am I missing something else?
Hardware: Tiva C Launchpad from TI
IDE: IAR Embedded Workbench
Thanks for any help,
William
Also, this is the .s file from IAR that I modified and added to my project. I'll just leave it here in case it provides any useful info.
/************************************************** * * Part one of the system initialization code, contains low-level * initialization, plain thumb variant. * * Copyright 2008-2017 IAR Systems AB. * * $Revision: 112610 $ * **************************************************/ ; ; The modules in this file are included in the libraries, and may be replaced ; by any user-defined modules that define the PUBLIC symbol __iar_program_start or ; a user defined start symbol. ; To override the cstartup defined in the library, simply add your modified ; version to the workbench project. ; ; The vector table is normally located at address 0. ; When debugging in RAM, it can be located in RAM, aligned to at least 2^6. ; The name "__vector_table" has special meaning for C-SPY, which ; is where to find the SP start value. ; If vector table is not located at address 0, the user has to initialize the NVIC vector ; table register (VTOR) before using interrupts. ; ; Cortex-M version ; MODULE ?vector_table AAPCS INTERWORK, VFP_COMPATIBLE, RWPI_COMPATIBLE PRESERVE8 CFI Names cfiNames0 CFI StackFrame CFA R13 DATA CFI Resource R0:32, R1:32, R2:32, R3:32, R4:32, R5:32, R6:32, R7:32 CFI Resource R8:32, R9:32, R10:32, R11:32, R12:32, R13:32, R14:32 CFI EndNames cfiNames0 CFI Common cfiCommon0 Using cfiNames0 CFI CodeAlign 2 CFI DataAlign 4 CFI ReturnAddress R14 CODE CFI CFA R13+0 CFI R0 Undefined CFI R1 Undefined CFI R2 Undefined CFI R3 Undefined CFI R4 SameValue CFI R5 SameValue CFI R6 SameValue CFI R7 SameValue CFI R8 SameValue CFI R9 SameValue CFI R10 SameValue CFI R11 SameValue CFI R12 Undefined CFI R14 SameValue CFI EndCommon cfiCommon0 ;; Forward declaration of sections. SECTION CSTACK:DATA:NOROOT(3) SECTION .intvec:CODE:NOROOT(2) EXTERN __iar_program_start PUBLIC __vector_table DATA __iar_init$$done: ; The vector table is not needed ; until after copy initialization is done __vector_table DCD sfe(CSTACK) DCD __iar_program_start DCD NMI_Handler DCD HardFault_Handler DCD MemManage_Handler DCD BusFault_Handler DCD UsageFault_Handler DCD 0 DCD 0 DCD 0 DCD 0 DCD SVC_Handler DCD DebugMon_Handler DCD 0 DCD PendSV_Handler DCD SysTick_Handler ;; ;; Device Specific Interrupts ;; DCD GPIOPortA_IRQHandler DCD GPIOPortB_IRQHandler DCD GPIOPortC_IRQHandler DCD GPIOPortD_IRQHandler DCD GPIOPortE_IRQHandler DCD UART0_IRQHandler DCD UART1_IRQHandler DCD SSI0_IRQHandler DCD I2C0_IRQHandler DCD PWMFault_IRQHandler DCD PWMGen0_IRQHandler DCD PWMGen1_IRQHandler DCD PWMGen2_IRQHandler DCD QEI0_IRQHandler DCD ADCSeq0_IRQHandler DCD ADCSeq1_IRQHandler DCD ADCSeq2_IRQHandler DCD ADCSeq3_IRQHandler DCD Watchdog_IRQHandler DCD Timer0A_IRQHandler DCD Timer0B_IRQHandler DCD Timer1A_IRQHandler DCD Timer1B_IRQHandler DCD Timer2A_IRQHandler DCD Timer2B_IRQHandler DCD Comp0_IRQHandler DCD Comp1_IRQHandler DCD Comp2_IRQHandler DCD SysCtrl_IRQHandler DCD FlashCtrl_IRQHandler DCD GPIOPortF_IRQHandler DCD GPIOPortG_IRQHandler DCD GPIOPortH_IRQHandler DCD USART2_IRQHandler DCD SSI1_IRQHandler DCD Timer3A_IRQHandler DCD Timer3B_IRQHandler DCD I2C1_IRQHandler DCD QEI1_IRQHandler DCD CAN0_IRQHandler DCD CAN1_IRQHandler DCD CAN2_IRQHandler DCD Ethernet_IRQHandler DCD Hibernate_IRQHandler DCD USB0_IRQHandler DCD PWMGen3_IRQHandler DCD uDMAST_IRQHandler DCD uDMAError_IRQHandler DCD ADC1Seq0_IRQHandler DCD ADC1Seq1_IRQHandler DCD ADC1Seq2_IRQHandler DCD ADC1Seq3_IRQHandler DCD I2S0_IRQHandler DCD EBI0_IRQHandler DCD GPIOPortJ_IRQHandler ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Default interrupt handlers. ;; PUBWEAK NMI_Handler PUBWEAK HardFault_Handler PUBWEAK MemManage_Handler PUBWEAK BusFault_Handler PUBWEAK UsageFault_Handler PUBWEAK SVC_Handler PUBWEAK DebugMon_Handler PUBWEAK PendSV_Handler PUBWEAK SysTick_Handler PUBWEAK GPIOPortA_IRQHandler PUBWEAK GPIOPortB_IRQHandler PUBWEAK GPIOPortC_IRQHandler PUBWEAK GPIOPortD_IRQHandler PUBWEAK GPIOPortE_IRQHandler PUBWEAK UART0_IRQHandler PUBWEAK UART1_IRQHandler PUBWEAK SSI0_IRQHandler PUBWEAK I2C0_IRQHandler PUBWEAK PWMFault_IRQHandler PUBWEAK PWMGen0_IRQHandler PUBWEAK PWMGen1_IRQHandler PUBWEAK PWMGen2_IRQHandler PUBWEAK QEI0_IRQHandler PUBWEAK ADCSeq0_IRQHandler PUBWEAK ADCSeq1_IRQHandler PUBWEAK ADCSeq2_IRQHandler PUBWEAK ADCSeq3_IRQHandler PUBWEAK Watchdog_IRQHandler PUBWEAK Timer0A_IRQHandler PUBWEAK Timer0B_IRQHandler PUBWEAK Timer1A_IRQHandler PUBWEAK Timer1B_IRQHandler PUBWEAK Timer2A_IRQHandler PUBWEAK Timer2B_IRQHandler PUBWEAK Comp0_IRQHandler PUBWEAK Comp1_IRQHandler PUBWEAK Comp2_IRQHandler PUBWEAK SysCtrl_IRQHandler PUBWEAK FlashCtrl_IRQHandler PUBWEAK GPIOPortF_IRQHandler PUBWEAK GPIOPortG_IRQHandler PUBWEAK GPIOPortH_IRQHandler PUBWEAK USART2_IRQHandler PUBWEAK SSI1_IRQHandler PUBWEAK Timer3A_IRQHandler PUBWEAK Timer3B_IRQHandler PUBWEAK I2C1_IRQHandler PUBWEAK QEI1_IRQHandler PUBWEAK CAN0_IRQHandler PUBWEAK CAN1_IRQHandler PUBWEAK CAN2_IRQHandler PUBWEAK Ethernet_IRQHandler PUBWEAK Hibernate_IRQHandler PUBWEAK USB0_IRQHandler PUBWEAK PWMGen3_IRQHandler PUBWEAK uDMAST_IRQHandler PUBWEAK uDMAError_IRQHandler PUBWEAK ADC1Seq0_IRQHandler PUBWEAK ADC1Seq1_IRQHandler PUBWEAK ADC1Seq2_IRQHandler PUBWEAK ADC1Seq3_IRQHandler PUBWEAK I2S0_IRQHandler PUBWEAK EBI0_IRQHandler PUBWEAK GPIOPortJ_IRQHandler SECTION .text:CODE:REORDER:NOROOT(1) CFI Block cfiBlock0 Using cfiCommon0 CFI Function __default_handler THUMB NMI_Handler HardFault_Handler MemManage_Handler BusFault_Handler UsageFault_Handler SVC_Handler DebugMon_Handler PendSV_Handler SysTick_Handler GPIOPortA_IRQHandler GPIOPortB_IRQHandler GPIOPortC_IRQHandler GPIOPortD_IRQHandler GPIOPortE_IRQHandler UART0_IRQHandler UART1_IRQHandler SSI0_IRQHandler I2C0_IRQHandler PWMFault_IRQHandler PWMGen0_IRQHandler PWMGen1_IRQHandler PWMGen2_IRQHandler QEI0_IRQHandler ADCSeq0_IRQHandler ADCSeq1_IRQHandler ADCSeq2_IRQHandler ADCSeq3_IRQHandler Watchdog_IRQHandler Timer0A_IRQHandler Timer0B_IRQHandler Timer1A_IRQHandler Timer1B_IRQHandler Timer2A_IRQHandler Timer2B_IRQHandler Comp0_IRQHandler Comp1_IRQHandler Comp2_IRQHandler SysCtrl_IRQHandler FlashCtrl_IRQHandler GPIOPortF_IRQHandler GPIOPortG_IRQHandler GPIOPortH_IRQHandler USART2_IRQHandler SSI1_IRQHandler Timer3A_IRQHandler Timer3B_IRQHandler I2C1_IRQHandler QEI1_IRQHandler CAN0_IRQHandler CAN1_IRQHandler CAN2_IRQHandler Ethernet_IRQHandler Hibernate_IRQHandler USB0_IRQHandler PWMGen3_IRQHandler uDMAST_IRQHandler uDMAError_IRQHandler ADC1Seq0_IRQHandler ADC1Seq1_IRQHandler ADC1Seq2_IRQHandler ADC1Seq3_IRQHandler I2S0_IRQHandler EBI0_IRQHandler GPIOPortJ_IRQHandler Default_Handler __default_handler CALL_GRAPH_ROOT __default_handler, "interrupt" NOCALL __default_handler B __default_handler CFI EndBlock cfiBlock0 END
Are you sure about the vector number?
I found GPIO J uses vector 67 (TM4C1294NCPDT).
I don't know what to say.. I double checked the table order and it turned out my handler was pointing to the wrong exception. After fixing it, it finally worked.
I went through all this trouble just because I didn't double check everything. Lesson learned I think. This seems to be a silly problem, but at least I learned more about startup files and disassembly because of this
Thanks to you and Bill.
Cheers
Ah. Thanks for the update!Yeah, all the memory dumps I asked for looked correct (maybe the technique will come in handy again sometime.)I was just getting around to "Wait, does the Tiva-C Launchpad even HAVE a Port J? Isn't that a TM4C123GH6PM that has vectors at 0x118 as "reserved"", and trying to figure our whether my documentation was up to date...
There are some other TM4C chips (TM4C123GH6PGE) with a PortJ vector at 118, but they're not (AFAIK) on Launchpads...
BTW, my main theory for the possibly-corrupt vector table was that somehow you had added your new vectors, but the compiler was still including the default vector table from "somewhere else", resulting in your vectors getting appended rather than located at 0...