We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I am using Keil uVision3 and have written code in C which includes three files as key.c,key.h and main.c. when I compile my code as error C129: missing ';' before '.' for the line exactly where I initialize my structure element to zero in key.c
My code is as follows:
File main.c
#include <REG51.H> #include "key.c" void main() { key_task(); while(1); }
File key.h
#ifndef KEYPAD_H_INCLUDED #define KEYPAD_H_INCLUDED sbit ke1=P2^0; sbit ke2=P2^1; sbit ke3=P2^2; sbit ke4=P2^3; sbit ds0=P3^4; sbit ds1=P3^5; sbit ds2=P3^6; sbit ds3=P3^7; typedef struct { unsigned char key_pres_cnt,key_rls_cnt,key_pres_flg,key_rls_flg,key_type,ket_status; }key; extern key k1,k2,k3,k4; enum key_stat{no_key_pres,key_pres}; void key_task(); #endif /*KEYPAD_H_INCLUDED*/
File key.c
#include <REG51.H> #include "key.h" key k1,k2,k3,k4; k1.key_pres_cnt=0; k1.key_pres_flg=0; k1.key_rls_cnt=0; k1.key_rls_flg=0; void key_task() { //Logic for first key if(ke1==no_key_pres) { if(k1.key_pres_cnt<10) k1.key_pres_cnt++; else { if(k1.key_pres_cnt) k1.key_pres_cnt--; } if(k1.key_pres_cnt>=10) { k1.key_pres_cnt=0; k1.key_pres_flg=1; } if(k1.key_pres_flg==1) ds0=0; if(ke1==key_pres) { if(k1.key_rls_cnt<10) k1.key_rls_cnt++; else { if(k1.key_rls_cnt) k1.key_rls_cnt--; } if(k1.key_rls_cnt>=10) { k1.key_rls_cnt=0; k1.key_rls_flg=1; k1.key_pres_flg=0; } if(k1.key_rls_flg==1) ds0=1; } } }
Please help me
Thanks in advance