Hi all
I am using STR9 board with RTX kernel on keil I want to use a hadware timer (timer2) in my code but the following code does not work it does not jump to interrupt handler as the overflow occurs but the same program works fine with normal without RTX is there any code or example to know how to deal with timer interrupt in RTX
/*---------------------------------------------------------------------------- * R T L K e r n e l E x a m p l e *---------------------------------------------------------------------------- * Name: BLINKY.C * Purpose: RTX example program * Rev.: V3.04a / 17-jan-2007 *---------------------------------------------------------------------------- * This code is part of the RealView Run-Time Library. * Copyright (c) 2004-2007 KEIL - An ARM Company. All rights reserved. *---------------------------------------------------------------------------*/ #include <RTL.h> #include <91x_lib.H> #include "LCD.h" #include "RT_Agent.h" /* Real-Time Agent definitions */ #include <stdio.h> u32 VIC_Mask = 1; void delay_ms (unsigned long nCount){ // Wait function nCount=nCount+16000000L; while (nCount--); } /* id1, id2, id3, id4 will contain task identifications at run-time */ OS_TID id1, id2, id3, id4,id5; u16 LedPulse = 0,tmp = 0; extern OS_TID tim_task; //OS_TID rd_task; unsigned char toggle=0; /* Forward reference */ void task1 (void) __task; void task2 (void) __task; void task3 (void) __task; void task4 (void) __task; void task5 (void) __task; OS_ID tmr1; short counter1; /* counter for task 1 */ #define LED1_GLOW() GPIO9->DR[0x3FC] = 0x0001 #define LED2_GLOW() GPIO9->DR[0x3FC] = 0x0002 #define LED3_GLOW() GPIO9->DR[0x3FC] = 0x0004 #define LED4_GLOW() GPIO9->DR[0x3FC] = 0x0008 #define LED1_OFF() GPIO9->DR[0x3FC]&= 0x1110 void SCU_INIT() { SCU->PCGR1 |=0x2; //enable timer2 and timer3 SCU->PCGR1 |=0x80000; //GPIO5 clock enable SCU->PCGR1 |=0x20000; //GPIO3 clock enable SCU->PCGR1 |=0x800000; //GPIO9 clock enable SCU->PCGR1 |=0x8; //uart0 clock enable SCU->PCGR1 |=0x20; //uart2 clock enable SCU->PCGR1 |=0x100000; //GPIO6 clock enable } void VIC_INIT() { u32 VIC_Mask = 1; SCU->PRR0 |=0x20; /*AHB peripheral not held in Reset*/ /* TIMER2 INTERRUPT ROUTENE*/ VIC0->VAiR[0] = (u32)TIM2_IRQHandler; //address of interrupt subroutene VIC0->INTSR &= ~(VIC_Mask << 6 ); //enables the IRQ interrupt for timer2 VIC0->VCiR[0] |= 0x20; //enables the vectored interrupt VIC0->VCiR[0] &= 0xFFFFFFE0; //clears the VCIR last 5 bits VIC0->VCiR[0] |= 6; // select the source for interrupt VIC0->INTER |= (VIC_Mask << 6); //enable the interrupt of timer2 } void led_init() { GPIO9->DDR = 0xFF; GPIO9->DR[0x3FC] = 0x0000; } /*---------------------------------------------------------------------------- * Task 1: RTX Kernel starts this task with os_sys_init (task1) *---------------------------------------------------------------------------*/ void task1 (void) __task { /* Obtain own system task identification number */ id1 = os_tsk_self (); os_tsk_prio_self (1); SCU_INIT(); VIC_INIT(); TIM_INIT(); UART2_GPIO_INIT(); UART2_INIT(); printf("uart2 working"); // id4 = os_tsk_create (task4, 1); led_init(); os_tsk_delete_self (); } /*---------------------------------------------------------------------------- *---------------------------------------------------------------------------*/ void task4 (void) __task { while (1) { printf("4"); if(tmp>0) { printf("9"); } } } int main (void) { os_sys_init (task1); // for(;;); } void TIM2_IRQHandler(void) { // Send event TIM2->SR &= ~0x2000; TIM2->SR &= ~0x4000; tmp++; printf("1"); if(toggle==0) { LED1_GLOW(); printf("2"); toggle=1; } else { printf("3"); LED1_OFF() ; toggle=0; printf("4"); } VIC0->VAR = 0; //Acknowledge Interrupt }
thanks