View previous topic :: View next topic |
Author |
Message |
wirelessage
Joined: 08 Aug 2012 Posts: 34
|
Bootloader relationship with Pin B5 |
Posted: Mon Aug 27, 2012 1:56 pm |
|
|
Hello:
I am just getting started to work on Bootloader code base for PIC 18F2680/2685. I observe that in the sample code that I got from CCS that Pin B5 is always expected to detect low on reset. Is there a reason for this?
Reason I ask is because we were planning to use that particular pin for two separate applications, one applications needs that pin to detect low while the other applications needs to detect it High.
If the pin is always expected to be read low for using the bootloader, I may not be able to design the hardware with a default configuration of the pin detected high on bootup.
Regards,
Wirelessage |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Aug 27, 2012 2:00 pm |
|
|
It's expected that a push-button to ground with a pull-up resistor on
the output side, is connected to Pin B5. To invoke the bootloader,
hold down the button on pin B5 and cycle the power on the board.
Upon power-up, the board will go into bootloader mode. |
|
|
wirelessage
Joined: 08 Aug 2012 Posts: 34
|
|
Posted: Mon Aug 27, 2012 3:16 pm |
|
|
Thanks for the quick reply!
I need to provide some context.
So, I guess the question is "is having pin B5 detect low on reset, a requirement for bootloader to run?". If that is the case, then it will mean that without any external circuitry (press button etc) I cannot have the setup where the bootloader runs detecting low on B5 and application f/w runs detecting a high on pin B5.
Please confirm. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Aug 27, 2012 3:26 pm |
|
|
There are other ways to invoke a bootloader without looking for a button
press upon power-up. You don't have to do it the way that CCS uses for
their example.
For example, when the application program is running normally, it can
poll a pin (or it could poll a flag that is set by an external interrupt).
If that pin goes low, then call the bootloader routine (go into bootload
mode). It would not actually return from the call, because the bootloader
code would execute the reset_cpu() function when it's done. See the
CCS manual for that function.
Or, the host program (such as a Windows application) could send a
command to the PIC to go into bootloader mode. It would do this when
the user selects "download Firmware" from a menu in the Windows app.
Or, if your control program is a TeraTerm window, you could type in
a special command and the PIC would go into bootload mode when it
sees that command. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Aug 27, 2012 3:54 pm |
|
|
Or, at power up you wait for a maximum of 2 seconds while scanning the UART for a special character.
This would mean that on the PC you start your special bootloader program. The PC transmits an endless stream of your special characters. Then on resetting the PIC it detects the character and goes into bootloader mode. PIC sends a 'bootload started' message to the PC and PC can start downloading.
This requires you to write a dedicated download program on the PC, but has the advantage that no button has to be pressed by the user. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Mon Aug 27, 2012 8:57 pm |
|
|
ckielstra wrote: | Or, at power up you wait for a maximum of 2 seconds while scanning the UART for a special character.
|
That's what I have on one device with an all text user interface.
I use the CCS written SIO and when the unit starts, it says to press '+' 3 times in 10 seconds and prints out '.' chars the whole time. (1 every second)
Then the normal program execution starts.
If the user DOES hit +++ in time, then it goes into program mode and expects to hear from SIO. _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Tue Aug 28, 2012 1:42 am |
|
|
Just to put this in context, and (hopefully), make it clear.
There is _no_ special relationship with pin B5.
A bootloader has to have some way of being 'triggered', and the simplest is a button. As a 'example', the standard bootloader assumes this to be on pin b5 (port b is always the favoured choice, since on most chips this port has built in pull-ups).
It is up to you to decide 'how' your 'bootloader' is going to be triggered. Could be any port pin, a pulse on a pin, a specific pattern of serial data, etc. etc..
It doesn't even have to be on 'wakeup' (this was covered some time ago), though it is the easiest way to do things, since then the code can be called automatically before the main code.
Best Wishes |
|
|
|