📄 main.c
字号:
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"
#include "Iis.h"
volatile unsigned int size=0;
static U32 TimerCnt=0;
static int LedStatus=0;
char *wavdata;
unsigned char *Buf,*_temp;
void __irq RxInt(void);
void __irq Timer_Tick(void)
{
rI_ISPC=BIT_TIMER3;
if(TimerCnt++ == 10) {
TimerCnt=0;
Led_Display(LedStatus);
LedStatus=(~(LedStatus)&0x7);
Uart_Printf("\nTIMER3 interrupt... ");
}
}
void __irq Timer_ISR(void)
{
rI_ISPC=BIT_TIMER0;
Uart_Printf("\nTIMER0 interrupt... ");
}
void Timer_Init(void)
{
/*
* Timer Clock Frequency = MCLK/pre/mux
*/
rTCFG0=0x00000f0f; //dead zone=0,pre2=0,pre1=0xf,pre0=0
rTCFG1=0x0000100a; //all interrupt,mux5=1/2,mux2=1/2,mux3=1/4,mux2=1/2,mux1=1/2,mux0=1/2
rTCNTB3=0xc000; //(1/(60MHz/4/15))*0xc350=50ms
//(1/(60MHz/4/15))*0x4320=20ms
rTCMPB3=0x010;
rTCNTB1=400;
rTCON=0x002000a; //update T3
rTCON=0x0090009; //T3=auto reload,start
rINTCON=0x5; //Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0; //All=IRQ mode
pISR_TIMER0=(unsigned)Timer_ISR;
pISR_TIMER3=(unsigned)Timer_Tick;
rINTMSK=BIT_GLOBAL;
// rINTMSK=~(BIT_GLOBAL|BIT_TIMER3 |BIT_TIMER0); //start timer INT
rINTMSK=~(BIT_GLOBAL|BIT_TIMER3);
}
void Main(void)
{
U32 i;
rSYSCFG=CACHECFG; // Using 8KB Cache//
Port_Init();
Uart_Init(0,57600);
Delay(10);
Uart_Select(0); //Select UART0
Led_Display(0x07);
pISR_URXD0=(unsigned)RxInt;
Uart_Printf("\nFS44B0X TIMER ");
Uart_Printf("\n定时器中断DEMO");
rINTCON=0x5; //Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0;
rINTMSK=~(BIT_GLOBAL|BIT_URXD0);
// Timer_Init();
Buf=(unsigned char *)0xc400000;
_temp=Buf;
for(i=0xc400000;i<(0xc400000+0xf0000);i+=4)
{
*((volatile unsigned *)i)=0x00;
}
Uart_Printf("Download the PCM(no ADPCM) wave file by wkcom2(with header)!!\n");
while(((unsigned int)_temp-(unsigned int)Buf)<4)
{
Led_Display(0xf);
Delay(1500);
Led_Display(0x0);
Delay(1500);
}
size=*(Buf) | *(Buf+1)<<8 | *(Buf+2)<<16 | *(Buf+3)<<24;
Uart_Printf("\nNow, Downloading... [FILESIZE:%7d( 0)",size);
while(((unsigned int)_temp-(unsigned int)Buf)<size)
Uart_Printf("\b\b\b\b\b\b\b\b%7d)",(unsigned int)_temp-(unsigned int)Buf);
Uart_Printf("\b\b\b\b\b\b\b\b%7d)\n",(unsigned int)_temp-(unsigned int)Buf);
rINTMSK |=BIT_URXD0;
// while(1)
// {
Play_BigWave(0xc400004,size);
//}
while(1);
}
void __irq RxInt(void)
{
rI_ISPC=BIT_URXD0 ; //clear pending bits
*_temp++=RdURXH0();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -