PDA

View Full Version : 16F88 bootlader with Internal OSC



HenrikOlsson
- 28th July 2009, 13:14
Hi guys,
Does anyone have a bootloader file for the 'F88 set up for the internal oscillator @4Mhz?

I've tried to import the one supplied with MCLoader (setup for external oscillator) into MPLAB and changing the Config bits manually but if I've figured this out correctly you also need to set the OSCCON-register to $68 in order for the internal oscillator to actually run at 4MHz. Initially I tried to change that in MPLAB as well (View->Special Function Registers)but obviously that won't work since the OSCON register is in RAM... doh...

So, does anyone have such a bootloader file or can assist me with a way to modify the existing one to work with the internal oscillator?

Oh, and I have verified serial comms using the USART by compiling a small program and programming the device with the PICStart+. It echos charcters sent to it at @2400baud so that part is working.

Thanks!
/Henrik.

BrianT
- 29th July 2009, 02:53
I just compiled a PBP program using the MeLabs USB serial programmer for the 16F88 on internal clock. I selected the 16F88_04 from C:\Program files\Mecanique\MCSP\MCLoader\16F88\16F88_04.

Call up the CONFIG word (click the 'C' beside the PIC16F88 dropdown) and there you can select the various clock modes you want.

In your code you will need an OSCCON statement to select 4 MHz and possibly a speed tweak via OSCTUNE.

Seems to work for me.

HTH
BrianT

HenrikOlsson
- 29th July 2009, 07:36
Thanks Brian,
That's pretty much what I've done. I import the 16F88_04.hex in MPLAP, change the config-bits to internal oscillator and program the chip with my PICSTART+.

BUT I can't get my application downloaded thru the bootloader since the command that sets the OSCCON register is in MY application program and not in the bootloader stub currently running on the chip.

The chip boots up on the internal oscillator @31.25kHz but since nothing in the bootloader .hex file sets the OSCCON register the chip keeps running at that speed and the bootloader is a no-go...

So what I need is to somehow modify the 16F88_04.hex file to include a command that sets OSCCON to $68 so that the chip speeds up from 31.25kHz to 4Mhz when it starts up....I think ;-)

Or did I completely missed your point?

Thanks again!
/Henrik.

Darrel Taylor
- 29th July 2009, 22:16
Hi Henrik,

Give this a try ...

I've modified the 16F88_04.HEX file to jump to a new location, set OSCCON to $60 (4mhz) then jump back to the bootloader.

I've changed the OSC to INTIO, and used the Serial Number dialog in meProg to modify certain locations of the HEX file with new RAW instructions.
It's kind of like flipping switches on the front panel of an Altair 8080. :eek:

I think it will work, but it's a bit of a gamble.

hth,

HenrikOlsson
- 29th July 2009, 22:47
Thanks a lot Darrel,
I'll give it a go first thing in the morning, concidering your track record I feel confident ;-) I'll let you know ASAP though.

I guess you changed the Goto bootloader adress to actually jump past the bootloader, setting OSCCON and then back to the bootloader? Or do I need to worry about overwriting those 'certain locations'?

Never used meProg but I did spend a couple of hours today looking for dissassemblers and stuff, found a few, some I couldn't get to work at all, and some showed me an asm listing but no way to save it without coughing up money (fair enough I guess).

And of course, OSCCON should be set to $60 and not $68, don't know why I was trying to set a read-only bit.....

Again, thanks alot!
/Henrik.

Darrel Taylor
- 30th July 2009, 00:36
I guess you changed the Goto bootloader adress to actually jump past the bootloader, setting OSCCON and then back to the bootloader? Or do I need to worry about overwriting those 'certain locations'?
Yes, there's a small area just past the bootloader that didn't appear to be used, and I only put about 5 words in there. So it won't affect the amount of code you would normally be able to use.

My only fear is if that area is used by the bootloader, it may only work once. I don't think it will overwrite it, but I can't test it here to be sure.

Fingers crossed.



And of course, OSCCON should be set to $60 and not $68, don't know why I was trying to set a read-only bit.....
Since you can't write to that bit ... a 1 is just as valid as a 0. :)

HenrikOlsson
- 30th July 2009, 08:32
Hi Darrel,
Your bootloader file seems to be working perfectly! I've only downloaded a few very short test-programs but so far but it seems to work just fine.

Now off to get a 100Hz timer interrupt going, with DT-Ints of course ;-)

Thank you!
/Henrik.

Darrel Taylor
- 30th July 2009, 17:16
Great. sometimes a gamble pays off.


Now off to get a 100Hz timer interrupt going, with DT-Ints of course ;-)
Of course. :)

Using the Timer Template ?
<br>

HenrikOlsson
- 1st August 2009, 10:32
Hi Darrel,
Yes, using the timer template I was able to get it going in a matter of minutes - awsome piece of work that Instant Interrupt system!

A bit OT: I've also started playing a bit with this Ladder compiler (http://cq.cx/ladder.pl) for PIC's, pretty cool and the hex-files it produces leaves the first four bytes of program memory empty so I can program the chip with MCLoader, sweet.

/Henrik.

Darrel Taylor
- 1st August 2009, 19:55
Hmmm, was it a Freudian slip.
Funny how the thread was spelled ... and it ends up you're using a Ladder program. :)

Back when I was working with PLC's I never really liked dealing with Ladder Logic.
That program you pointed to brought back some Scary memories.

But thanks for pointing it out, because I'm really interested in the SolveSpace (http://solvespace.com/index.pl) program on the same website.

That'll suck up a few hundred hours of my time. :)
<br>

HenrikOlsson
- 2nd August 2009, 10:15
Hi Darrel,
Yeah, I noticed I had mis-spelled the thread title, I hate it when that happens and I can't seem to figure out how to go back and edit it.

I'm not very comfortable with ladder programming myself but I think it has its place. I did look at the solve space video on the site, pretty cool, please don't disappear from here ;-)

/Henrik.