Jump to content
Sign in to follow this  
cart

Pic16f877 Bootloader?

Recommended Posts

Hi!

 

I was looking for a good tiny bootloader for 16f877. I have used one PIC bootloader +, but for some reason it doesn't work correctly. It doesn't start my program in power up. I have to do MCLR reset and randomly it starts my own program.

 

Any better loader or fix for this?

Share this post


Link to post
Share on other sites

cart,

 

This sounds like a hardware fault.

Check oscillator settings and components used. Maybe the osciallator doesn't start sometimes.

 

What happens if you don't use bootloader, does you code then start every time ?

 

Regards

Dave

Share this post


Link to post
Share on other sites
What happens if you don't use bootloader, does you code then start every time ?

 

Yes, it starts every time without bootloader.

 

Seems that first 4 bytes, which bootloader copies to another location, doesn't work correctly. I'm not so familiar with PIC ASM, but I think that BoostC generates code where jump to start of program is a 'short jump'. Then when bootloader does this 'short jump' from another bank, PC jumps to somewhere in unused memory.

For some reason it sometimes works.

 

Can I change BoostC to do this jump as a 'far jump' somehow?

Share this post


Link to post
Share on other sites

Ok. Found the problem. It is that damn short jump. How can I change BoostC to make startup code so that it would do a long jump? So it has to do:

 

movlw 0x00;high byte of long jump
movwf 0xA;zero PCLATH

 

before jumping to startup.

 

Is it possible?

Share this post


Link to post
Share on other sites
Doesn't anyone have any idea to fix this problem?

 

Hi Cart,

 

 

I have read the whole thread and maybe the answer is in there, but....

 

On my first Bootloader experiment I had similar problems and was thinking about the bootloader code too. The PIC ran sometimes when I hit the reset button.

Later I found that I could stop and start the PIC by placing my finger on the PIC. Finger o, PIC stopped. Finger away, PIC ran. So no bootloader problem.

 

The remedy: You need a pull down resistor on pin RB3. RB3 is the PGM command pin in LV-programming mode. If you leave the pin floating, little is needed to push and pull the PIC in and out of programming mode. A 1(one) is PGM, a 0 (zero) is run.

The f877 comes default from the factory in LV-programming.

 

 

With best regards.

 

 

Frans.

Share this post


Link to post
Share on other sites

... same problem here (that damn datasheet is too long)

But to me it was sufficient to set RB3 as a low output (no resistor, no connections).

 

Is there any difference or advantage between the two solutions?

Share this post


Link to post
Share on other sites
... same problem here (that damn datasheet is too long)

But to me it was sufficient to set RB3 as a low output (no resistor, no connections).

 

Is there any difference or advantage between the two solutions?

 

 

Hi azoto,

The two methods are totally different.

 

Changing the pin direction is done wit a running PIC.

 

If the LV-programming function is enabled, and that is what you want with a bootloader, the PIC will sense the RB3 pin on start-up/reset, if this pin is sensed as '1' the PIC will switch to programming mode.

So if it happens that RB3 is '1' during startup the PIC will go into programming until RB3 becomes '0, on which normal operation will start, unless RB3 interferes again before the PIC has reached the direction change instruction.

 

 

Leaving an input pin open will bias the pin to the digital 0/1 threshold, so any disturbance picked up by the pin wil swith the state of the pin input detector.

 

So tying RB3 with a resistor to ground ensures that RB3 is '0' during startup/rest. The value should not be too low and too high, I normally use 10K, this value is high enough so it will not load the output of RB3 or another source when RB3 is used as a digital pin.

 

Hope its clear enough.

 

With best regards,

 

 

Frans.

Share this post


Link to post
Share on other sites

Hi Frans, please allow me only one question, I'm a newbie and want to learn...

 

If the LV-programming function is enabled, and that is what you want with a

 

Why do you need the LVP to be enabled if you're using a bootloader? I thought the BL only needs the code not to be protected... Am I completely wrong?

 

Hope its clear enough.

 

It's crystal clear! Thanks a lot for your explanation. :)

I'll tie down RB3 with a 10K resistor to avoid any further issue.

 

Kind regards

Share this post


Link to post
Share on other sites
Hi Frans, please allow me only one question, I'm a newbie and want to learn...

 

If the LV-programming function is enabled, and that is what you want with a

 

Why do you need the LVP to be enabled if you're using a bootloader? I thought the BL only needs the code not to be protected... Am I completely wrong?

 

Hope its clear enough.

 

It's crystal clear! Thanks a lot for your explanation. :)

I'll tie down RB3 with a 10K resistor to avoid any further issue.

 

Kind regards

 

Hi azoto,

 

 

You are right I do not know for sure you need the LV-programming together with a bootloader.

The thing I know is that the LV-programming comes defaulted from the factory on the f877.

You can only switch it off, but you need HV-programming to get it back on, so the datasheet says.

 

 

With best regads,

 

Frans.

Share this post


Link to post
Share on other sites
Why do you need the LVP to be enabled if you're using a bootloader? I thought the BL only needs the code not to be protected... Am I completely wrong?

 

You do not need LVP to use a Bootloader. Unfortuately Microchips enabling LVP by default was a poor judgement decision on their part.

 

A correctly written bootloader should disable the LVP flag in the config register.

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...