Re: Blinking LED with C18




"BrunoG" <noreply@xxxxxxxxxxxxxxxxxx> wrote in message
news:44118ed1$0$18324$8fcfb975@xxxxxxxxxxxxxxxxxx
"Abstract Dissonance" <Abstract.Dissonance@xxxxxxxxxxx> a écrit dans le
message de news: 1212q9mpt5j2s31@xxxxxxxxxxxxxxxxxxxxx
I'm trying to blink an LED using C18 in MPLAB but the code doesn't work
for some reason. It is the exact code that came from one of there
examples... but the LED doesn't blink or even come on. I tried doing
some other stuff but it didn't work either(and I commented it out).

I can't understand why this code doesn't work since "they" created but it
doesn't. I was able to make the 16F688 blink using assembly but I'm
trying to get it done in C with the 18F2455.

Anyone see why this isn't working?

Thanks,
Jon

---------------------------------------------

#include <p18f2455.h>

#pragma config WDT = OFF

void delay (void)
{
int i;

for (i = 0; i < 10000; i++)
{
};

}

void main (void)
{
/* Make all bits on the Port B (LEDs) output bits.
* If bit is cleared, then the bit is an output bit.
*/

//ADCON0 = 0;
// ADCON1 = 0x6;
TRISB = 0;
// TRISA = 0;
// TRISC = 0;

while (1)
{
/* Reset the LEDs */
// PORTA = 0;
PORTB = 0;
// PORTC = 0;

/* Delay so human eye can see change */
delay ();

/* Light the LEDs */
// PORTA = 0xFF;
PORTB = 0xFF;
// PORTC = 0xFF;

/* Delay so human eye can see change */
delay ();
}
}





Hi,
try to add :

ADCON1 = 0x0E ;

to configure RB0..4 as digital I/O pins

check also extended instruction flag bit in configuration registers, this
is a common issue migrating from p16 to p18

Regards,

Bruno
http://www.micro-examples.com/public/microex-navig/doc/200-pic-microcontroller-examples.html


ok, I'll try.

Thanks,
Jon


.



Relevant Pages

  • Blinking LED with C18
    ... but the LED doesn't blink or even come on. ... void delay (void) ... /* Make all bits on the Port B (LEDs) output bits. ...
    (sci.electronics.basics)
  • Re: Blinking LED with C18
    ... It is the exact code that came from one of there ... I was able to make the 16F688 blink using assembly but I'm ... void delay (void) ... /* Make all bits on the Port B (LEDs) output bits. ...
    (sci.electronics.basics)
  • Re: Blinking LED with C18
    ... I was able to make the 16F688 blink using assembly but I'm ... void delay (void) ... /* Make all bits on the Port B (LEDs) output bits. ...
    (sci.electronics.basics)
  • Re: PATCH : LEDs - possibly the most pointless kernel subsystem ever
    ... Nope -- I have just hacked together a driver to expose the keyboard leds ... release (void * ignored) ... set_state (unsigned int idx, unsigned char state, void *ignored) ...
    (Linux-Kernel)
  • Forth 10 times slower than C?
    ... I've tried to use Forth on a LPC2148 microcontroller, ... void initPorts() ... void blink() ... but what can I expect from a Forth cross compiler? ...
    (comp.lang.forth)