Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC 18F4550 code on microC pro, simulation on Proteus not working!

Status
Not open for further replies.

Uptech19

Newbie level 2
Joined
Dec 16, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,298
Hello every one, I have been facing a problem regarding my code for PIC for quite a few days now,
I am new to PIC programming in microC since i have only worked on 8051 microcontrollers and keil,
I would really appreciate it if some one can kindly tell me what am I doing wrong in the code given below!

// code to switch on LED when push button at pin RA0 is pressed and off when it is released

sbit LED at RB0_bit;
sbit LED_Direction at TRISB0_bit;
sbit SW at RA0_bit;
sbit SW_Direction at TRISA0_bit;

void main()
{
ADCON1= 0x0F;
CMCON = 0x07;
LED_Direction = 0; // setting pin B0 as output
SW_Direction= 1 ; // setting pin A0 as input
TRISD= 0; // setting port D as output
while(1);
{

if (SW==0)
{
LED=1;
}
PORTD = 0xff;
Delay_1sec;
PORTD = 0x0f;
if (SW==1)
{
LED=0;
}
}
}

its a simple code to switch on and Off an LED when button is pressed but its not simulating in proteus!
thank you in advance

here is the proteus design

https://obrazki.elektroda.pl/27_1324276294.jpg
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top