mcu52
Newbie level 1
- Joined
- Mar 18, 2012
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,287
MicroC AC Controller syntax problem "pic16f88"
Hi, i'm having a problem where i got syntax error for the following code. Can anyone help.
the problem saying that "is not applicable to these operands 'INTCON, Undeclared identifier 'Lcd_Custom_Config' in expression "
Can anyone help. thanks.
Hi, i'm having a problem where i got syntax error for the following code. Can anyone help.
Code:
//**********************************************************************
/*
AC Controller
*/
//**********************************************************************
static unsigned short controlFlag;
static unsigned short sleepTimeTemp;
static unsigned short sleepTime;
void interrupt()
{
if (INTCON.T0IF == 1) {
INTCON.T0IF = 0;
TMR0 = 170;
//
if (controlFlag == 1) {
if (sleepTimeTemp > 0) {
if (sleepTimeTemp == 1) {
PORTA.F2 = 1;
}
sleepTimeTemp--;
} else {
PORTA.F2 = 0;
}
}
}
if (PIR1.TMR1IF == 1) { // 200msec
PIR1.TMR1IF = 0;
PORTB.F1 = ~PORTB.F1;
}
if (INTCON.INTF == 1) { // 8msec (60Hz)
INTCON.INTF = 0;
sleepTimeTemp = sleepTime;
}
}
//**********************************************************************
void Pwm_Change_DutyEx(unsigned int duty_ratio)
{
CCPR1L = duty_ratio >> 2;
CCP1CON.F6 = duty_ratio & 0b00000001;
CCP1CON.F7 = (duty_ratio & 0b00000010) >> 1;
}
//**********************************************************************
void main()
{
static unsigned int ad1;
static unsigned short cnt, i;
static unsigned long l;
static unsigned char buf[10];
//
CMCON = 0b00000111;
ANSEL = 0b00000010;
TRISA = 0b00111010;
TRISB = 0b00000101;
OSCCON = 0b01110000;
OPTION_REG = 0b00001000;
T1CON = 0b00110001;
OPTION_REG.INTEDG = 0;
INTCON.GIE = 0;
INTCON.PEIE = 1; // Peripheral Interrupt Enable
INTCON.TMR0IE = 1; // TMR0 Overflow Interrupt Enable
INTCON.TMR0IF = 0; // TMR0 Overflow Interrupt Flag
INTCON.INTE = 1; // RB0/INT External Interrupt Enable
PIE1.TMR1IE = 1; // TMR1 Overflow Interrupt Enable
PIR1.TMR1IF = 0; // TMR1 Overflow Interrupt Flag
T2CON.T2CKPS0 = 0;
T2CON.T2CKPS1 = 0;
//
Pwm_Init(2000); // 2Khz
Pwm_Change_DutyEx(1024 / 2);
//
Lcd_Custom_Config(&PORTB,4,5,6,7,&PORTA,0,7,6);
TRISB = 0b00000101;
TRISA = 0b00111010;
//
controlFlag = 0;
sleepTime = 0;
sleepTimeTemp = 0;
//
Lcd_Custom_Cmd(LCD_CURSOR_OFF);
for (cnt = 0; cnt < 5; cnt++) {
Lcd_Custom_Out(1, 1, "AC contr");
Lcd_Custom_Out(2, 1, "ol R1.1");
Pwm_Start();
Delay_ms(200);
Pwm_Stop();
Lcd_Custom_Cmd(LCD_CLEAR);
Delay_ms(200);
}
//
INTCON.GIE = 1;
//
while (1) {
//
if (PORTA.F3 == 1) {
ad1 = Adc_Read(1);
sleepTime = 127 - (ad1 / 8);
} else {
if (PORTA.F4 == 0) {
if (sleepTime < 127)
sleepTime++;
Pwm_Start();
Delay_ms(50);
Pwm_Stop();
}
if (PORTA.F5 == 0) {
if (sleepTime > 0)
sleepTime--;
//
Pwm_Start();
Delay_ms(50);
Pwm_Stop();
}
}
//
switch (sleepTime) {
case 0:
controlFlag = 0;
PORTA.F2 = 1;
break;
case 127:
controlFlag = 0;
PORTA.F2 = 0;
break;
default:
controlFlag = 1;
}
//
cnt = (127 - sleepTime) / 10; // 0...12
for (i = 1; i < 9; i++) {
if (cnt > 0) {
cnt--;
Lcd_Custom_Chr(1, i, 0xFF);
} else {
Lcd_Custom_Chr(1, i, ' ');
}
}
for (i = 1; i < 5; i++) {
if (cnt > 0) {
cnt--;
Lcd_Custom_Chr(2, i, 0xFF);
} else {
Lcd_Custom_Chr(2, i, ' ');
}
}
//
l = (long)sleepTime;
l = ((127 - sleepTime) * 100) / 127;
WordToStr(l, buf);
buf[5] = '%';
buf[6] = 0x00;
Lcd_Custom_Out(2, 5, &buf[2]);
//
Delay_ms(1);
}
}
//**********************************************************************
the problem saying that "is not applicable to these operands 'INTCON, Undeclared identifier 'Lcd_Custom_Config' in expression "
Can anyone help. thanks.
Last edited by a moderator: