compiling ak.c...
ak.c(34): error: #268: declaration may not appear after executable statement in block
ak.c(34): error: #67: expected a "}"
compiling common.c...
程序如下: (
忘指点1‘2,万分感谢)
#include "M051.h"
#include "Register_Bit.h"
#include "common.h"
#define uchar unsigned char
#define uint unsigned int
uchar K_FLAG; //Óмü°´×ÅÖÃ1£¬ËÉ¿ªÇå0
uchar K_FIRST;
uchar disp_sel;
uchar COUNT=0;
uchar add1_buf=0;
uchar const seg_data[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
uchar const bit_data[]={0xf7,0xfb,0xfd,0xfe};
uchar disp_buf[4];
void Delay_ms(uint xms)
{
uint i,a;
for(i=xms;i>0;i--)
for(a=115;a>0;a--);
}
void C74LS164(uchar j)
{
char i;
for(i=0;i<8;i++)
{
P05_DOUT=0;
if(j&0x80)
P04_DOUT=0;
else
P04_DOUT=1;
j=j<<1;
P05_DOUT=1;
Delay_ms(3);
}
void Display(void)
{
uchar tmp;
tmp=disp_buf[disp_sel];
tmp=seg_data[tmp];
C74LS164(tmp);
tmp=bit_data[disp_sel];
P0_DOUT=tmp;
disp_sel++;
if(disp_sel==4)
disp_sel=0;
}
void KeyProcess()
{
uchar temp;
P1_DOUT|=0x0f; //½«4¸ö°´¼üÖÃ1²»Ó°ÏìÆäËûλ
temp=P1_DOUT; //¶ÁÈ¡°´¼ü
temp|=0xf0; //½«ÆäÓàΪÖÃ1ÒÔ±ãÅжÏ
temp=~temp; //½«ÆäÈ¡·´£¬Èç¹ûûÓа´¼ü°´ÏÂÔòΪ0£¬Óа´¼ü°´ÏÂÔòΪ1
if(!temp) //ÎÞ°´¼ü°´ÏÂÇå±ê־λ
{
K_FLAG=0;
K_FIRST=0;
return;
}
if(!K_FLAG) //ÅжÏÊÇ·ñµÚÒ»´Î°´ÏÂ
{
COUNT=4;
K_FLAG=1;
return;
}
COUNT--;
if(COUNT!=0)
return;
if(P10_DOUT==0)
add1_buf++;
else
{
K_FLAG=0;
K_FIRST=0;
}
if(K_FIRST)
COUNT=25;
else
{
COUNT=250;
K_FIRST=1;
}
}
void TMR0_Init(void)
{
IPRSTC2|=TMR0_RST; //¸´Î»TMR0Ä£¿é
IPRSTC2&=TMR0_RST; //À뿪¸´Î»
APBCLK|=TMR0_CLKEN; //ʹÄÜTMR0ʱÖÓ
CLKSEL1=CLKSEL1&(~TM0_CLK)|TM0_12M; //Ñ¡Íⲿ12MΪTMR0ʱÖÓ
TCSR0=TCSR0&(~TMR_MODE)|MODE_PERIOD; //Ñ¡¶¨ÖÜÆÚģʽ
TCSR0&=0xffffff00; //²»·ÖƵ
TCMPR0=12000*3; //3ms;
TCSR0|=TMR_IE; //¿ªÖжÏ
NVIC_ISER|=TMR0_INT; //¿ªÖжÏ
TCSR0|=CRST; //¸´Î»ÏòÉϼÆÊýÆ÷ºÍCEN
TCSR0&=CRST; //À뿪¸´Î»
TCSR0|=CEN;
}
void TMR0_IRQHandler(void)
{
Display();
KeyProcess();
}
int main()
{
TMR0_Init();
Un_Lock_Reg();
PWRCON|=XTL12M_EN;
while((CLKSTATUS&XTL12M_STB)==0);
CLKSEL0=CLKSEL0&(~HCLK)|HCLK_12M;
Lock_Reg();
P01_DOUT=0;
P0_PMD=P0_PMD&(~(Px0_PMD|Px1_PMD|Px2_PMD|Px3_PMD|Px4_PMD|Px5_PMD))|
(Px0_OUT|Px1_OUT|Px2_OUT|Px3_OUT|Px4_OUT|Px5_OUT); //ÉèÖÃP0~5½ÅΪÊä³ö¹¦ÄÜ
P1_PMD=P1_PMD&(~Px0_PMD)|Px0_OUT;
for(;;)
{
disp_buf[0]=add1_buf%10;
disp_buf[1]=add1_buf/10%10;
disp_buf[2]=add1_buf/10/10%10; //È¡°Ùλ
disp_buf[3]=add1_buf/1000; //ȡǧλ
}
}
|