本帖最后由 Ricky001 于 2011-3-13 18:44 编辑
程序如下
#include<pic.h>
unsigned char table[ ] = { 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90} ;
char dat ;
void delay ( void )
{
int i ;
for( i = 0 ; i<400 ; i++) ;
}
void display( unsigned char k )
{
TRISA = 0x00 ;
PORTC = table[ k/1000 ];
PORTA = 0xEF ;
delay( ) ;
PORTC = table[ k/100%10 ] ;
PORTA = 0xDF ;
delay( ) ;
PORTC = table[ k/10%10 ] ;
PORTA = 0xFB ;
delay( ) ;
PORTC = table[ k%10 ] ;
PORTA = 0xF7 ;
delay( ) ;
}
void main( void )
{ char dat ; unsigned char datavalue ;
TRISA = 0x00 ; //初始化
TRISC = 0x00 ;
PORTC = 0xFF ;
TRISD = 0xFF ;
while( 1 )
{
dat = (PORTD & 0xF0) ;
if ( dat = =0x20 )
datavalue = 0x01 ;
if ( dat = =0x40)
datavalue = 0x02 ;
if ( dat = =0x10)
datavalue = 0x03 ;
if ( dat = =0x80)
datavalue = 0x04 ;
display( unsigned char datavalue ) ;
NOP( ) ;
}
}
錯誤提示如下
Error [195] C:\pt\pt.c; 37.12 expression syntax
Error [194] C:\pt\pt.c; 38.18 ")" expected
Error [195] C:\pt\pt.c; 39.12 expression syntax
Error [194] C:\pt\pt.c; 40.18 ")" expected
Error [195] C:\pt\pt.c; 41.12 expression syntax
Error [194] C:\pt\pt.c; 42.18 ")" expected
Error [195] C:\pt\pt.c; 43.12 expression syntax
Error [194] C:\pt\pt.c; 44.18 ")" expected
请问这是为什么呀 |