Discussion in "PIC Microcontroller Discussion" started by    kingrosekhan123    Oct 18, 2014.
Sat Oct 18 2014, 01:46 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, 11:12 AM
#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, 06:08 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, 06:11 PM ]

Get Social

Information

Powered by e107 Forum System

Conversation

No messages yet.

Downloads

Comments

Mirza123
Thu Jun 25 2020, 03:46 PM
eunicelove124
Mon Jun 22 2020, 03:03 PM
cerouno
Tue Jun 16 2020, 05:10 PM
Marce
Sat Jun 13 2020, 09:43 PM
Davidthils
Thu May 21 2020, 12:44 PM
Jakeror
Thu May 21 2020, 01:28 AM
motorCar
Wed May 20 2020, 07:05 PM
Vordrync
Wed May 20 2020, 11:52 AM

Online

Guests: 104, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123