Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] PIC UART bootloader considerations

Status
Not open for further replies.

Alloy

Advanced Member level 4
Joined
Apr 3, 2016
Messages
116
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
1,003
Hey
How to write a UART bootloader for PIC?
Is this a hard task or easy?
Do I need only RX/TX lines or something else and if yes, why?
Will you recommend me any good reading resources for that?
Also how it happens that bootloader code does not confict with uploaded hex?
Thanks in advance!
 

Hi,

Read just any of many thousand documentation about pic bootloader wil answer almost all of your questions.

My questions:
You look for a bootloader for a PIC, the manufacturer of PIC is microchip. They have documents how to write your own bootloader. Did you read them?
If you were at the microchip internet sites you surely foud out that there are ready to use bootoaders (microchip and/or others). Why don't you use them?

You are lucky to live in a country with free access to the internet. You can use search engines like google - many people in the world don't have this acccess. So take your chance and use it. Learn how to use it.
Like: "bootloader site:microchip.com"
--> https://www.google.de/search?q=bootloader+site:microchip.com

Klaus
 

Hello Alloy,

don't forget that do you need a Pickit2 or 3 to first put the bootloader into your virgin MCU !

OR

If you want a Ready for use MCU with a bootloader in it , you can use

MikroE supplier:
Ready For Pic Board ex 18F45K22
a StartUSB PIC Board 18F2550
Clicker PIC18F47J53
Clicker2 PIC18F87J50
.. etc ....
or other suppliers


Also how it happens that bootloader code does not confict with uploaded hex?
with Mikroe HID bootloader, never mind about this problem
it's transparent.
(Except that you loose some FlashRom space for your application, take care about ..)

Do I need only RX/TX lines or something else and if yes, why?
The bootloader is a programme wich establish a dialogue with a PC computer
So you need somme INput/outPut to do this exchange of data
it is mainly with trough UART RX TX serial link
or via Virtual Port COM PC USB<-> FTDI<-> UART PIC

or direct via USB on somme evoluate PIC as 18F87J50
very high speed to download the HEX file to the PIC.
 

Also what other lines are needed depends how you want to use the bootloader.
If you only want to use it when power is turned on (i.e. you need to begin the connection with the external programmer device within a given number of seconds after power on) and not otherwise, then the Rx and Tx lines alone can be enough.
If you want an external trigger to enter the bootloader mode then you will need an external line or some programmed method that needs to be within your application.
As to the bootloader itself, you need to consider what you expect from it. If you want to be able to debug through the bootloader (i.e. effectively have it as a PicKit 3 within the device) then it will be rather complex. On the other hand if you just want to use it as a in-field firmware upgrade tool then it should be a lot simpler.
Also consider the various failure modes - what happens if the reprogramming fails due to something like a communication error: do you need to double-buffer the new application so that you can do a complete CRC check (or similar) with the new code before switching from the old app? If so this will take twice the memory footprint but provide you with a fall-back if the upgrade fails in a critical device.
Otherwise is there a way to regain control through the bootloader if the upgrade fails (should be if you use a power-on timed approach or an external line etc.).
Do you ever want to upgrade the bootloader?
If you want to write your own then you need to consider at least these questions. If you use a bootloader form somewhere else then you still need to consider these questions to see if it can deliver the results you want.
Having said all of that, I get the feeling you are not an experienced programmer (otherwise you would probably know the level of difficulty and the ways to mask off the bootloader program within the flash memory etc) in which case I would suggest that you start by gaining more general embedded programming experience before moving up to this type of exercise.
Susan
 

Ok, thanks for the replies. I have still some questions.

How do I reset a PIC MCU from external digital 5V level logica pin?
I mean... I think about NPN transistor that will be directly between MCLR and GND.... but:
1. do I have to add some reistor on base, and do I calculate it somehow?
2. that 5V level logical pin will be only sometimes powered, do I have to add some kind of pull-up or pull-down for cases when there is no power on the progamming circuit?
 

Hi,

You may use a NPN on low active reset signals.
For sure you have to take care about all the specifications of all devices.
Here: mainly currents. You need to take care the the current at tge reset line is within it's limits,
As well as base current.
And: yes, you (and all we also) have to calculate the resistors, as long as they are not given in the datasheets and /or application notes.

And yes, you (and we) need to take care of all the possible situations. So you may add pullup or pulldown resistors

It's impossible to give more precise answers without schematic and other informations.
Therefore I recommend: draw your schematic, completely. Then post it, so we can give our hints.

Klaus
 

So I image it like that:
trans.png
I did not draw pull down/pull up of base transtistor signal because I dont know where to put it (before base resistor or after)...

PS: I always use button instead of transtistor (simple PIC reset button) but now I need to it to be transtistor.
 

Hi,

Speaking for me:
* I don't know if PIC Reset is high active or low active. According your schematic it seems to be low active.
* I don't know if you want the trasitor_base_reset signal to be high active or low active. It seems to be high active.
* I don't know what transistor you want to use. Any standard NPN will do. (Do you already have one or do you need to buy one). Therefore I don't kniw what ghe datasheet says about base current. I can only guess that 0.5mA are sufficient.
You need to know Ohm's law and how to use it. There's no way around. If you don't know this niw you have to learn it immediately.

Pullup/pulldown:
We don't have the informations to answer it.
Transistor: if you want to ensure that it is OFF, then use a pulldown at it's base. ON --> pullup.

At the collector there is a pullup already.

Klaus
 

You don't need a pulldown resistor for the transistor base. Pullups/pulldowns are usually used for FETs to prevent a floating condition.

Almost any value is fine for the base resistor, as you just want to minimize current consumption from whatever is sourcing it. Your collector current is already going to be low, because of the 10K load, so your base resistor could be anything up to around 220K. Just throw a 10K in there. If you need to conserve power use 100K.
 

* I don't know if PIC Reset is high active or low active. According your schematic it seems to be low active.
Low state = (tied to ground) = RESET active.
That's why I am replacing button with transtistor. But there will be a button as well.


* I don't know if you want the trasitor_base_reset signal to be high active or low active. It seems to be high active.
No difference...
Pullup/pulldown:
We don't have the informations to answer it.
Transistor: if you want to ensure that it is OFF, then use a pulldown at it's base. ON --> pullup.

At the collector there is a pullup already.

I want to have NO RESET when the base input pin is floating...
 

Hi

I want to have NO RESET when the base input pin is floating...

My reccomedation is: pull the base low.

Indeed the base itself needs no pulldown, but any additional connection to the base will introduce erroneous currents.
Assuming you need 400uA collector curent and you use a bjt with an hFE of 800, then a tiny current of 500nA may trigger a reset. (for sure this are worst case - but maybe real - conditions)
Flux residuals, lengthy wires, humidity, ESD, EMC, capacitive coupling....all this introduces current/voltage into the base line.

Therefore a 10k pulldown will move sensitivity to about 50uA (= 100 times 500nA).
I develop industrial measurement/control equippment --> I´d never leave a base of a bjt unconnected, and for sure not at a "sensitive" signal like RESET.

Klaus
 

Do I connect the base pulldown directly to the base or by the another resistor?

See
 

hello,

i always use this:

Image1.jpg

maybe, wait for other advise..
 
  • Like
Reactions: Alloy

    Alloy

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top