PDA

View Full Version : 18f4550 running slow?



Giulio
- 14th October 2012, 21:55
Hi,

I recently upgraded to the latest version of pbp3, and it came with mplab 8.85. I'm using these with an ICD2, and the latest versions at first seemed to be less 'buggy' [I used to get spurious errors regularly with previous software versions].

I dusted off some old test projects, and all was well with the 16f628A and 18f2550 stuff I wrote a while back.

However, when I swapped out the 18f2550 from my breadboard, and inserted a 18f4550, things weren't right. I went back to the most basic code, the tried and trusted flashing LED and, sure enough, it seems to be running over ten times slower than it should, at a guesstimate.

The code runs perfectly on a 18f2550, flashing the LED around once a second, but takes over ten seconds on a 18f4550. No problem, I thought, it's an oscillator setting, and so I started changing the config bits. After a whole day pulling my hair out, I cannot get it to work with what seems to be the right timing. I have tried every configuration possible [I'm sure], and no go.


I built a MIDI footpedal for a friend, a while ago, and had the project archived. I re-compiled it, and it doesn't work, that's without changing a line of code. What I now have is the most basic breadboard setup. Connections to Vdd, Vss, PGD, PGC, MCLR [tied with 10k resistor], 20mhz crsytal, and an LED from RB0.

As I said, unplug the perfectly working 18f2550, plug in the 18f4550, change the device and download the 18f4550 code within mplab, and the LED runs over ten times slower.

I Googled 18f4550 running slow, and found one applicable result, and the person on that forum put it down to a pcb issue, and it was never resolved satisfactorily.

I'm convinced it's a software issue, as I have had small 18f4550 projects, including a USB one, working ok.

Has anybody else run into this issue with this device? I need the extra pins on the 4550 for my next project, and it's *really* frustrating to be able to plug a 2550 back in and watch it work perfectly!


The simplest 'code' in the world is included below. I have manually tried changing the config bits, and re-programming again and again, to no avail.

Any pointers would be much appreciated.


G



DEFINE OSC 20

;---------------------------------------------------------------------------------------------
#config
__CONFIG _CONFIG1H, _FOSC_HS_1H
#endconfig
;---------------------------------------------------------------------------------------------

main:

TRISB = 0
lp1:
portb.0 = 1
pause 1000
portb.0 = 0
pause 1000

goto lp1

Demon
- 14th October 2012, 22:48
Try with this:


@ __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
@ __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
@ __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _BORV_1_2L & _VREGEN_ON_2L
@ __CONFIG _CONFIG2H, _WDT_OFF_2H
@ __CONFIG _CONFIG3H, _CCP2MX_OFF_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
@ __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L

DEFINE OSC 48

TRISA = %00000000
TRISB = %00000000
TRISC = %00000000
TRISD = %00000000
TRISE = %00000000

ADCON1 = %00001111

Led VAR PORTC.2

LoopThis:
TOGGLE Led
PAUSE 500
GOTO LoopThis

END

The led should blink real close to 1 second intervals.

Robert
:)