主题 : arm2440,产生一波形,程序有问题,求指导! 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 60776
精华: 0
发帖: 4
金钱: 20 两
威望: 4 点
综合积分: 8 分
注册时间: 2011-12-16
最后登录: 2011-12-31
楼主  发表于: 2011-12-21 21:16

 arm2440,产生一波形,程序有问题,求指导!


请问大侠我这个程序哪里出了问题呢?怎么产生不了上面的那个波形呢!下载到板上都没反应!该如何修改呢?跪求解答!万分感谢!arm2440!
#define    GLOBAL_CLK        1
#define _ISR_STARTADDRESS 0x33ffff00
#define U32 unsigned int
#define pISR_TIMER4 (*(unsigned *)(_ISR_STARTADDRESS+0x58))
#define rSRCPND (*(volatile unsigned *)0x4a000000)
#define rINTMSK (*(volatile unsigned *)0x4a000008)
#define rINTPND (*(volatile unsigned *)0x4a000010)
#define rGPBCON (*(volatile unsigned *)0x56000010) //Port B control
#define rGPBDAT (*(volatile unsigned *)0x56000014) //Port B data
#define rGPBUP (*(volatile unsigned *)0x56000018) //Pull-up control B
#define rTCFG0 (*(volatile unsigned *)0x51000000) //Timer 0 configuration
#define rTCFG1 (*(volatile unsigned *)0x51000004) //Timer 1 configuration
#define rTCON (*(volatile unsigned *)0x51000008) //Timer control
#define rTCNTB4 (*(volatile unsigned *)0x5100003c) //Timer count buffer 4



#include "def.h"
#include "2440addr.h"
#include "2440lib.h"
#include "2440slib.h"


void __irq Timer4_ISR(void)
{
    static int count;
    count ++;
    rSRCPND = rSRCPND | (0x1<<14);
    rINTPND = rINTPND | (0x1<<14);
    switch(count)
    {
     case 1:   rGPBDAT= 0x020;break;
     case 10:  rGPBDAT= 0x060;break;
     case 25:  rGPBDAT= 0x020;break;
     case 71:  rGPBDAT= 0x060;break;
     case 138: rGPBDAT= 0x020;break;//GPB5,GPB6为信号输出
     case 183: rGPBDAT= 0x000;count=0;break;
     default:break;
    }
}

int Main(void)
{
    rCLKDIVN=0x00;  //1:1:1    其中FCKL=400MHZ
    rGPBCON = 0x155555; //B0输出,给蜂鸣器;B5~B8输出,给LED      用于可感实验,不用管它,不会影响程序
    rGPBUP = 0x7ff;
    rGPBDAT = 0x1e0; //蜂鸣器不响,LED灭                          用于可感实验,不用管它,不会影响程序
    rSRCPND = rSRCPND | (0x1<<14);
    rINTPND = rINTPND | (0x1<<14);
    rINTMSK = ~(0x1<<14); //打开定时器4中断
    rTCFG0 &= 0xFF00FF;
    rTCFG0 |= 0x300; // prescaler等于3
    rTCFG1 &= ~0xF0000;
    rTCFG1 |= 0x00; //divider等于2,则设置定时器4的时钟频率为//50MHz
    rTCNTB4 =1; //让定时器4每隔0.02us中断一次
    rTCON &= ~0xF00000;
    rTCON |= 0x700000;
    rTCON &= ~0x200000 ; //定时器4开始工作
    pISR_TIMER4 = (U32)Timer4_ISR;//中断后把程序送到定时器4的中断端口执行
    while(1);//等待中断
    return 0;
}