在线时间0 小时
UID2077220
注册时间2014-3-5
NXP金币0
该用户从未签到
新手上路

- 积分
- 13
- 最后登录
- 1970-1-1
|
求高手指点错误。
main.c
/*
* main implementation: use this sample to create your own application
*
*/
#include "support_common.h" /* include peripheral declarations and more */
#if (CONSOLE_IO_SUPPORT || ENABLE_UART_SUPPORT)
/* Standard IO is only possible if Console or UART support is enabled. */
#include
#endif
#include " IT1.h"
#define uchar unsigned char
uchar count1=0;
uchar count2=0;
uchar i;
void main(void)
{
PIT1_init;
EnableInterrupts;
PIT1_start(9999);
while(1)
{
i=count2;
}
}
PIT1.c
#include " IT1.h"
extern count2;
uchar con_PIT1;
/**********************************PIT1初始化*****************************/
void PIT1_init()
{
MCF_PIT_PCSR(1)=MCF_PIT_PCSR_RLD
|MCF_PIT_PCSR_PIF
|MCF_PIT_PCSR_PIE
|MCF_PIT_PCSR_OVW
|MCF_PIT_PCSR_PRE(4);//fPIT=fsys/2/2^PER
//at 80MHz
//0- 40000000Hz
//1- 20000000Hz
//2- 10000000Hz
//3- 5000000Hz
//4- 2500000Hz -0.4us
//5- 1250000Hz
//6- 625000Hz
//7- 312500Hz
//8- 156250Hz
//9- 78125Hz -12.8us
//10-39062.5Hz _25.6us
//11-19531.25Hz
//12-9765.625Hz
//13-4882.8125Hz
//14-2441.40625Hz
//15-1220.703125Hz
//|MCF_PIT_PCSR_DBG;
//|MCF_PIT_PCSR_DOZE
MCF_PIT_PMR(1)=9999;
MCF_INTC1_IMRL&=~MCF_INTC_IMRL_MASKALL;
MCF_INTC1_IMRH&=~MCF_INTC_IMRH_INT_MASK56;//PIT1
MCF_INTC1_ICR56=MCF_INTC_ICR_IP(6)+MCF_INTC_ICR_IL(2);//PIT1
}
/*******************************************************************************************/
void PIT1_start(uint x)
{
MCF_PIT_PMR(1)=x;
MCF_PIT_PCSR(1)|=MCF_PIT_PCSR_EN;
}
/********************************************************************************************/
void PIT1_stop(void)
{
MCF_PIT_PCSR(1)&=~MCF_PIT_PCSR_EN;
}
/********************************************************************************************/
__declspec(interrupt) void PIT1_handler(void)//interrupt source 56
{
MCF_PIT_PCSR(1)|=MCF_PIT_PCSR_PIF;//清除PIT标志位
if(con_PIT1++==500)
{
con_PIT1=0;
count2++;
}
}
中断向量表已改
asm_exception_handler, /* 114 (0x___) Reserved */
asm_exception_handler, /* 115 (0x___) Reserved */
asm_exception_handler, /* 116 (0x___) Reserved */
asm_exception_handler, /* 117 (0x___) Reserved */
asm_exception_handler, /* 118 (0x___) Reserved */
asm_exception_handler, /* 119 (0x___) Reserved */
PIT1_handler, /* PIT1 */
asm_exception_handler, /* 121 (0x___) Reserved */
asm_exception_handler, /* 122 (0x___) Reserved */
asm_exception_handler, /* 123 (0x___) Reserved */
asm_exception_handler, /* 124 (0x___) Reserved */
错误不知道在哪里,找的例程全部是PIT0的,照着例程改PIT1的,结果进不去,求高手解决。
|
|