Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 6 months ago.
The problems in the timer about S3C2440A
Hiall,thank you for reading my post.I met some problems when I am working on a school project about writing program of timer.Does anyone here can help me? Please look at the program:
- include "2440addr.h"
- include "def.h"
- include <stdarg.h> #define _ISR_STARTADDRESS 0x33ffff00
static unsigned int flag = 1;
/*************/ /* LED部分 */ /*************/
- define Led1_Off() {rGPADAT &= ((1 << 5));}
- define Led1_On() {rGPADAT |= (1 << 5);}
- define Led2_Off() {rGPADAT &= ((1 << 4));}
- define Led2_On() {rGPADAT |= (1 << 4);}
- define Led3_Off() {rGPADAT &= ((1 << 3));}
- define Led3_On() {rGPADAT |= (1 << 3);}
- define Led4_Off() {rGPADAT &= ((1 << 2));}
- define Led4_On() {rGPADAT |= (1 << 2);}
void Led_Init(void) { rGPACON &= (0xf <<2); }
/*************/ /* 定时器部分 */ /*************/ /*
- 启动代码中已经设置了系统时钟,PCLK = 50M
- 若TIMER0获得25KHZ的时钟源,选择分频50M/25K = 2000
- 2000 = 250 * 8 ,所以prescaler等于249,divider等于8
- TCFG0控制预分频,TCFG1控制分频
- TCNTB0/TCMPB0定时器0计数缓冲寄存器和比较缓冲寄存器
- 详细参看S3C2440寄存器手册
- / void Timer0_Init(void) { rTCFG0 &= (0xff) ; rTCFG0 |= 249 ; rTCFG1 &= (0xf) ; rTCFG1 |= 0x02 ; rTCNTB0 = 12500 ;0.5s中断一次
rTCON |= (1 << 1) ;手动更新 rTCON &= (1 << 1) ; rTCON |= 0x09 ; 自动加载,清除手动更新位,启动定时器 }
/*************/ /* 中断部分: */ /*************/ /*
- 开启定时器0中断INTMSK第10位是TIMER0的标志位
- / void Timer0_Interrupt_Init(void) {
rINTMSK &= (1 << 10) ; }
/*************/
/*************/ /*
- 中断处理:关闭LED1,记得清除中断
- / void irq Timer0_Isr(void) { rSRCPND |= 1 << 10 ; rINTPND |= 1 << 10 ; flag=!flag;
if (flag) { Led1_On(); } else { Led1_Off(); }
}
void Isr_Init(void) { pISR_TIMER0 = (U32)Timer0_Isr ; } /*************/
int Main() { Led_Init() ; Timer0_Interrupt_Init(); Timer0_Init(); Isr_Init() ;
while(1) {
- }
return 0; } I wrote a program about timer’s interruption of S3C2440A .(this one: http://www.kynix.com/Detail/1171588/S3C2440A-30.html )However,It has no react when operating. I has review the hardware,it’s no problems cause the same one can operate in other uart interruption besides the timer interruption.I have saw someone said that maybe the start code has some wrong in setting the interrupt site.But I have review,I feel it’s no problems. I can’t make a sure. Now my school project also need to use this.I am so worry cause I always can’t solve this troubles. Could you help me? Thanks a lot!