i am trying to develop my own project based on 8051. i am using Fingerprint sensor(R305) , AT89S52 and relay for basic relay on/off. given code is not completed i mean i have not included the relay function because it gives error at initial phase.
i am getting too much errors and actually i am new for this platform so please help mehttps://www.rhydolabz.com/wiki/?p=15770
#define _XTAL_FREQ 18432000 #include <REGX51.h> //#include <xc.h> //#include<pic.h> #include <stdio.h> #include <stdlib.h> void interrupt SerialRxPinInterrupt(void); void serialwrite(char ch); void serialprint(char *str); int sendcmd2fp(char *pack, int len); void matchFinger(); void serialFlush(); // BEGIN CONFIG #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled) #pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming) #pragma config CPD = OFF // datas EEPROM Memory Code Protection bit (datas EEPROM code protection off) #pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control) #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) //END CONFIG #define SPBRG #define TRISC7 #define TRISC6 #define GIE #define TXIF #define TXREG #define uchar unsigned char #define uint unsigned int #define RCIF #define LCDPORTDIR TRISA #define LCDPORT PORTA #define RS RE1 #define EN RE0 #define SWPORTdir TRISD #define SWPORT PORTD #define PASS 0 #define ERROR 1 #define i #define checkKey(id) id=up<down?++id:down<up?--id:id; uchar buf[20]; uchar buf1[20]; volatile uint index=0; volatile int flag=0; uint msCount=0; uint g_timerflag=1; volatile uint count=0; uchar datas[10]; uint id=1; enum { CMD, DATA, SBIT_CREN=4, SBIT_TXEN, SBIT_SPEN, }; const char passPack[]={0xEF, 0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0x7, 0x13, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1B}; const char f_detect[]={0xEF, 0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0x3, 0x1, 0x0, 0x5}; const char f_imz2ch1[]={0xEF, 0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0x4, 0x2, 0x1, 0x0, 0x8}; const char f_imz2ch2[]={0xEF, 0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0x4, 0x2, 0x2, 0x0, 0x9}; const char f_createModel[]={0xEF,0x1,0xFF,0xFF,0xFF,0xFF,0x1,0x0,0x3,0x5,0x0,0x9}; char f_storeModel[]={0xEF,0x1,0xFF,0xFF,0xFF,0xFF,0x1,0x0,0x6,0x6,0x1,0x0,0x1,0x0,0xE}; const char f_search[]={0xEF, 0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0x8, 0x1B, 0x1, 0x0, 0x0, 0x0, 0xA3, 0x0, 0xC8}; char f_delete[]={0xEF,0x1,0xFF,0xFF,0xFF,0xFF,0x1,0x0,0x7,0xC,0x0,0x0,0x0,0x1,0x0,0x15}; void serialbegin() { SCON=0x50; // Configure serial control registern PCON=0x80; // SMOD bitm set TMOD=0x20; // Using timer1,8-bitn reload mode for baudrate generation TH1=0xF7; // 9600 baudrate(16 mhz clock) TR1=1; // Start timer } void serialwrite(char ch) { char TXREG; TXREG =char ch ; while(!TXIF); // Wait till the transmitter bvbr becomes empty TXIF=0; // Clear transmitter flag // load thevbvc to be transmitted into transmit reg } void serialprint(char *str) { while(*str) { serialwrite(*str++); } } void interrupt SerialRxPinInterrupt(void) { if((PIR1bits.RCIF == 1) && (PIE1bits.RCIE == 1)) { uchar RCREG; uchar ch=RCREG; buf[index++]=ch; if(index>0) flag=1; int RCIF; RCIF = 0; // clear rx flag } } void serialFlush() { for(int i=0;i<sizeof(buf);i++) { buf[i]=0; } } int sendcmd2fp(char *pack, int len) { uint res=ERROR; serialFlush(); index=0; __delay_ms(100); for(int i=0;i<len;i++) { serialwrite(*(pack+i)); } __delay_ms(1000); if(flag == 1) { if(buf[0] == 0xEF && buf[1] == 0x01) { if(buf[6] == 0x07) // ack { if(buf[9] == 0) { uint datas_len= buf[7]; datas_len<<=8; datas_len|=buf[8]; for(int i=0;i<datas_len;i++) datas[i]=0; for(int i=0;i<datas_len-2;i++) { datas[i]=buf[10+i]; } res=PASS; } else { res=ERROR; } } } index=0; flag=0; return res; } } void matchFinger() { lcdwrite(1,CMD); lcdprint("Place Finger"); lcdwrite(192,CMD); __delay_ms(2000); if(!sendcmd2fp(&f_detect[0],sizeof(f_detect))) { if(!sendcmd2fp(&f_imz2ch1[0],sizeof(f_imz2ch1))) { if(!sendcmd2fp(&f_search[0],sizeof(f_search))) { lcdwrite(1,CMD); lcdprint("Finger Found"); uint id= datas[0]; id<<=8; id+=datas[1]; uint score=datas[2]; score<<=8; score+=datas[3]; sprintf(buf1,"Id:%d Score:%d",id,score); // relay control codes lies here usingg if statements lcdwrite(192,CMD); lcdprint(buf1); LED=1; __delay_ms(1000); LED=0; } else { lcdwrite(1,CMD); lcdprint("Not Found"); } } } else { lcdprint("No Finger"); } __delay_ms(2000); } // main function starts here................................................................ int main() { void (*FP)(); ADCON1=0b00000110; LEDdir= 0; SWPORTdir=0xF0; SWPORT=0x0F; serialbegin(57600); LCDPORTDIR=0x00; TRISE=0; lcdbegin(); lcdprint("Fingerprint"); lcdwrite(192,CMD); lcdprint("Interfacing"); __delay_ms(2000); lcdwrite(1,CMD); lcdprint("Using PIC16F877A"); lcdwrite(192,CMD); lcdprint("Circuit Digest"); __delay_ms(2000); index=0; while(sendcmd2fp(&passPack[0],sizeof(passPack))) { lcdwrite(1,CMD); lcdprint("FP Not Found"); __delay_ms(2000); index=0; } lcdwrite(1,CMD); lcdprint("FP Found"); __delay_ms(1000); lcdinst(); while(1) { FP=match<enrol?matchFinger:enrol<delet?enrolFinger:delet<enrol?deleteFinger:lcdinst; FP(); } return 0; }
Please post the error as text - copy and paste from the 'Build Output'
Also identify where, exactly, that error relates to in the code you posted.
er nischal said:i am new for this platform
Could you clarify what you mean by that?
If you're just starting out, why would you start with the AT89S52 ?
Keil C51 Documentation: http://www.keil.com/support/man_c51.htm
Specifically, for getting started: http://www.keil.com/support/man/docs/uv4cl/uv4cl_ex_hello.htm
General programming books: http://www.keil.com/books/
8051-specific books: http://www.keil.com/books/8051books.asp
sorry for that sir, i am new to AT89S52 based micrconontroller in general and keil C51 tools as well.
My output errors seems at line number 8.
errors:
compiling oldfingerprintreference.c...oldfingerprintreference.c(8): error C141: syntax error near 'interrupt', expected 'hdata'oldfingerprintreference.c - 1 Error(s), 0 Warning(s).