Questions:
I programmed my pic18F452 with the following code and plugged it into the circuit at http://www.ug.cs.usyd.edu.au/~odsouza/ but all the outputs (ie port B) are floating ie not grounded nor is there output voltage. Is that right?/* * This is example 1 from "Getting Started with MPLAB C18". */ #include <p18f452.h> /* for TRISB and PORTB declarations */ /* Set configuration bits for use with ICD2 / PICDEM2 PLUS Demo Board: * - set HS oscillator * - disable watchdog timer * - disable low voltage programming */ #pragma romdata CONFIG _CONFIG_DECL(_CONFIG1H_DEFAULT & _OSC_HS_1H,\ _CONFIG2L_DEFAULT,\ _CONFIG2H_DEFAULT & _WDT_OFF_2H,\ _CONFIG3H_DEFAULT,\ _CONFIG4L_DEFAULT & _LVP_OFF_4L,\ _CONFIG5L_DEFAULT,\ _CONFIG5H_DEFAULT,\ _CONFIG6L_DEFAULT,\ _CONFIG6H_DEFAULT,\ _CONFIG7L_DEFAULT,\ _CONFIG7H_DEFAULT); #pragma romdata int counter; void main (void) { counter = 0x0F; TRISB = 0; /* configure PORTB for output */ PORTB = counter; /* display value of 'counter' on the LEDs */ } 2nd code I tried /* * This is example 1 from "Getting Started with MPLAB C18". */ #include <p18f452.h> /* for TRISB and PORTB declarations */ /* Set configuration bits for use with ICD2 / PICDEM2 PLUS Demo Board: * - set HS oscillator * - disable watchdog timer * - disable low voltage programming */ #pragma romdata CONFIG _CONFIG_DECL(_CONFIG1H_DEFAULT & _OSC_HS_1H,\ _CONFIG2L_DEFAULT,\ _CONFIG2H_DEFAULT & _WDT_OFF_2H,\ _CONFIG3H_DEFAULT,\ _CONFIG4L_DEFAULT & _LVP_OFF_4L,\ _CONFIG5L_DEFAULT,\ _CONFIG5H_DEFAULT,\ _CONFIG6L_DEFAULT,\ _CONFIG6H_DEFAULT,\ _CONFIG7L_DEFAULT,\ _CONFIG7H_DEFAULT); #pragma romdata int counter; void main (void) { counter = 1; TRISB = 0; /* configure PORTB for output */ while (counter < 0xFF) { PORTB = counter; /* display value of 'counter' on the LEDs */ counter++; } }