高级会员
- 积分
- 991
- 威望
- 669
- 贡献
- 176
- 兑换币
- 69
- 注册时间
- 2011-7-20
- 在线时间
- 74 小时
|
10贡献
刚刚上手MCF52259 在调输出比较的时候很奇怪啊
我使用默认的总线频率 应该是80M,然后GPT的时钟64分频,
下面贴出GPT的初始程序,和主程序,
当主程序执行到while(1)的时候 GPT的计数器就会有溢出了,想不通 为什么计数器会走的这么快啊 从0x0000 到0xffff 需要60MS多啊,难道执行一条语句需要这么久的时间? 求高手指导,还有 rec++; 这条语句居然是不能设置断点了,我狂晕啊!!!
void GPTPA_Init(void)
{
MCF_GPIO_PTAPAR |= //GPT3 USD FOR GPT
MCF_GPIO_PTAPAR_ICOC0_ICOC0 //GPT0 USD FOR ICOC OC
|MCF_GPIO_PTAPAR_ICOC1_ICOC1; //GPT1 USD FOR ICOC OC
MCF_GPT_GPTSCR1 &= (~MCF_GPT_GPTSCR1_GPTEN); //禁止GPT
MCF_GPT_GPTSCR2 |= MCF_GPT_GPTSCR2_PR(6) //设置GPT时钟
|MCF_GPT_GPTSCR2_TOI; //enable counter overflow interupt
MCF_GPT_GPTFLG1 &= ~(MCF_GPT_GPTFLG1_CF0 //CLEAR ALL FLAG
|MCF_GPT_GPTFLG1_CF1
|MCF_GPT_GPTFLG1_CF2
|MCF_GPT_GPTFLG1_CF3
);
MCF_GPT_GPTFLG2 &= ~MCF_GPT_GPTFLG2_TOF;
MCF_GPT_GPTIOS |= MCF_GPT_GPTIOS_IOS0 //configure GPT0 GPT1 for OC
|MCF_GPT_GPTIOS_IOS1;
MCF_GPT_GPTDDR |= MCF_GPT_GPTDDR_DDRT0 //configure DDR xxxx xx11
|MCF_GPT_GPTDDR_DDRT1;
MCF_GPT_GPTC0 = 0x00ff; //configure GPTCO GOTC1
MCF_GPT_GPTC1 = 0xfff0;
MCF_GPT_GPTCTL1 |= MCF_GPT_GPTCTL1_OUTPUT0_TOGGLE //configure toggle
|MCF_GPT_GPTCTL1_OUTPUT1_TOGGLE;
MCF_GPT_GPTTOV |= MCF_GPT_GPTTOV_TOV0 //toggle when counter overflow
|MCF_GPT_GPTTOV_TOV1;
MCF_GPT_GPTIE |= MCF_GPT_GPTIE_CI0 //enable interupe channel 0and 1
|MCF_GPT_GPTIE_CI1;
MCF_INTC0_IMRL &= ~MCF_INTC_IMRL_MASKALL; //
MCF_INTC0_IMRH &= ~MCF_INTC_IMRH_INT_MASK44; //GPT C0F
MCF_INTC0_IMRH &= ~MCF_INTC_IMRH_INT_MASK45; //GPT C1F
MCF_INTC0_IMRH &= ~MCF_INTC_IMRH_INT_MASK41; //GPT TOV
MCF_INTC0_ICR44 = MCF_INTC_ICR_IP(6)+MCF_INTC_ICR_IL(2); //设置中断优先级别
MCF_INTC0_ICR45 = MCF_INTC_ICR_IP(5)+MCF_INTC_ICR_IL(2); //设置中断优先级别
MCF_INTC0_ICR41 = MCF_INTC_ICR_IP(4)+MCF_INTC_ICR_IL(2); //设置中断优先级别
}
int main(void)
{
uint8 Delay_time;
// char Reciver[10];
uint8 rec = 0;
MCF_GPIO_PTIPAR=0x00; //均为普通IO口
MCF_GPIO_DDRTI=0xff;
MCF_GPIO_PORTTI=0xf0;
MCF_GPIO_PTJPAR=0x00; //均为普通IO口
MCF_GPIO_DDRTJ=0xff;
MCF_GPIO_PORTTJ=0xf0;
uart0_init(9600);
PIT1_Init();
GPTPA_Init();
EnableInterrupts;
// MCF_PIT1_PCSR |= MCF_PIT_PCSR_EN;
MCF_GPT_GPTSCR1 |= MCF_GPT_GPTSCR1_GPTEN; // ENABLE GPT
rec++;
// printf("uart0 has recieved a char! it is %c\n",rec);
while(1)
{
;
}
}
|
|