0
\$\begingroup\$

I have comfortably got to grips with the pic16's now, so I am moving on up to the pic18 series.

However, I cannot get any joy from them.

I have a pic18f4455 and a pic18f14k50 - neither of which I can get to work. I really want to get the 4455 to go.

I have the usual xtal+2cap oscillator circuit, which is oscillating happily. I have the usual blinking-led program flashed into it. But it's just not running the program. My theory is that the overly-complex CONFIG registers aren't set right.

I am using sdcc on Ubuntu, and I have my config set up like this:

__code char __at __CONFIG1L c1l = _USBPLL_CLOCK_SRC_FROM_96MHZ_PLL_2_1L & _CPUDIV__OSC1_OSC2_SRC___1__96MHZ_PLL_SRC___2__1L & _PLLDIV_NO_DIVIDE__4MHZ_INPUT__1L;
__code char __at __CONFIG1H c1h = _OSC_HS__HS_PLL__USB_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H;
__code char __at __CONFIG2L c2l = _VREGEN_OFF_2L & _PUT_OFF_2L & _BODEN_OFF_2L;
__code char __at __CONFIG2H c2h = _WDT_DISABLED_CONTROLLED_2H;
__code char __at __CONFIG3H c3h = _PBADEN_PORTB_4_0__CONFIGURED_AS_DIGITAL_I_O_ON_RESET_3H & _LPT1OSC_OFF_3H & _MCLRE_MCLR_ON_RE3_OFF_3H;
__code char __at __CONFIG4L c4l = _LVP_OFF_4L & _ENHCPU_OFF_4L;                    // Disable LVP
__code char __at __CONFIG5L c5l = _CP_0_OFF_5L & _CP_1_OFF_5L & _CP_2_OFF_5L & _CP_3_OFF_5L;
__code char __at __CONFIG5H c5h = _CPD_OFF_5H & _CPB_OFF_5H;
__code char __at __CONFIG6L c6l = _WRT_0_OFF_6L & _WRT_1_OFF_6L & _WRT_2_OFF_6L & _WRT_3_OFF_6L;
__code char __at __CONFIG6H c6h = _WRTD_OFF_6H & _WRTB_OFF_6H & _WRTC_OFF_6H;
__code char __at __CONFIG7L c7l = _EBTR_0_OFF_7L & _EBTR_1_OFF_7L & _EBTR_2_OFF_7L & _EBTR_3_OFF_7L;
__code char __at __CONFIG7H c7h = _EBTRB_OFF_7H;

I know some of those aren't needed, but I have tried with nothing, just the needed ones, and with everything. Nothing seems to work.

I don't know what the best way of setting the config registers on this chip is in sdcc - g00gle doesn't seem to have much of a clue unless you're using MPLAB.

So, any clues? Anything I just haven't been able to see because it's so blindingly obvious?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Remove all that config stuff, and just turn off the WDT. It should run off the 8 MHz internal oscillator, and flash your LED. I can do that with the similar PIC18F2455. If that doesn't work you might have a hardware problem.

You will find things much easier if you use MPLAB and the C18 compiler. If you don't want to use Windows you might be able to use the new MPLAB-X, there is a Linux version.

\$\endgroup\$
13
  • \$\begingroup\$ Tried that already - no joy. Neither of the pic18s I have want to do anything. I didn't know there was a Linux version of mplab now - downloading it now. \$\endgroup\$
    – Majenko
    May 27, 2011 at 20:45
  • \$\begingroup\$ From within MPLAB, you can specify the configuration registers (Configure -> Configuration bits) and see what the actual hex values should be. You can then write those directly with sdcc instead of concatenating flags. \$\endgroup\$ May 27, 2011 at 21:19
  • \$\begingroup\$ Can't get mplab-x working - the installer just segv's. Could be because I'm in 64 bit linux? \$\endgroup\$
    – Majenko
    May 27, 2011 at 21:49
  • 1
    \$\begingroup\$ @Madmanguruman, if your compiler can't binary-AND constants together, you have bigger problems than config bits \$\endgroup\$
    – markrages
    May 27, 2011 at 22:36
  • \$\begingroup\$ @Leon, you are incorrect that SDCC is more complex than MPLAB+C18 \$\endgroup\$
    – markrages
    May 27, 2011 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.