Discussion in "PIC Microcontroller Discussion" started by    kingrosekhan123    Oct 18, 2014.
Sat Oct 18 2014, 07:16 pm
#1
i try this code but i dnt know where is the problem. i didnt understand the error.
please check that.
am using Hi-tech compiler along with MPLAB LDE 8.90

#include<htc.h>



__CONFIG(1, OSCSDIS & HSPLL);
// Config word 2
__CONFIG(2, BORDIS & PWRTDIS & WDTDIS);
// Config word 3
__CONFIG(3, CCP2RC1);
// Config word 4
__CONFIG(4, LVPEN & STVREN);
// Config word 5, 6 and 7 (protection configuration)
__CONFIG(5, UNPROTECT);
__CONFIG(6, WRTEN);
__CONFIG(7, TRU);



void main()
{
TRISB=0;
PORTB=0X00;
while(1)
{
test(a)
__delay_ms(1000);
switch(a)
{
case 0: a=0; break;
case 1: a=1; break;
case 2: a=2; break;

}
}
}

void test()
{
switch(int a)
{
case 1: PORTB=0x55; break;
case 2: PORTB=0xAA; break;
case 3: PORTB=0xFF; break;


}
} 
Mon Oct 20 2014, 04:42 pm
#2
I think you need to first check your code what exactly are you doing. Is it the first time you are writing C code? Where is variable a defined?
Tue Oct 21 2014, 11:38 pm
#3
i didnt understand the error

where is error is that syntax error or something else
look like program is not complete


[ Edited Tue Oct 21 2014, 11:41 pm ]

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am