CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Bootloader relationship with Pin B5

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
wirelessage



Joined: 08 Aug 2012
Posts: 34

View user's profile Send private message

Bootloader relationship with Pin B5
PostPosted: Mon Aug 27, 2012 1:56 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Aug 27, 2012 2:00 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Aug 27, 2012 3:16 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Aug 27, 2012 3:26 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Aug 27, 2012 3:54 pm     Reply with quote

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: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Aug 27, 2012 8:57 pm     Reply with quote

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: 19348

View user's profile Send private message

PostPosted: Tue Aug 28, 2012 1:42 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group