Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

PIC18f452 C-Code problem for C18 tool suite

Status
Not open for further replies.

talhataj

Newbie level 3
Joined
Nov 22, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,327
Hi Guys,

I m new to C language and currently working on programming of a PIC18f452 microcintroller. To get a start, i wrote a simple LED blinking code on MPLAB using C18 toolsuite, the code seems to be compiling and hex file is created without any errors, but after burning it on the controller the LED doesnt seem to flash, Please help

#include <stdlib.h>
#include <stdio.h>
#include <p18f452.h>//definitions of input/output pins
#include <portb.h>//functions to control pull-up resistors and interrupts
#pragma config WDT = OFF, OSC = XT, LVP = OFF, STVR = OFF, DEBUG = OFF, WRT0 = OFF, WRT1 = OFF, CP0 = OFF, CP1 = OFF, CPD = OFF, BOR = OFF

#include <delays.h> //This loads the delay functions. (See the library document.)

void main()
{
PORTA = 0x00; //set RA0-RA5 low
TRISA = 0x00; //set PORTA to output
//superloop
while(1)
{
PORTA = !PORTA;
//delays(250);
Delay1KTCYx(1000000000);
//_delay(250);
}
}

Regards
Talha
 

Joined
Jul 25, 2012
Messages
1,192
Helped
170
Reputation
340
Reaction score
161
Trophy points
1,343
Activity points
0
Is it
Code:
 PORTA = !PORTA;
or
Code:
 PORTA = ~PORTA;
? Also you should use LATA instead of PORTA.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top