0
\$\begingroup\$

I have doubts about the boot sequence of about every microcontroller but since I own a PIC I figure I should start with those first. I would like someone to explain how the PIC's boot sequence progresses. While explaining that I would also like to know how the PIC sets its clock setting such as internal or external clock without first knowing which one to use does it use its internal clock and then sets the clock to external once the register has been set?

\$\endgroup\$
  • \$\begingroup\$ This depends on a PIC family. Some can switch to the internal oscillator when user-defined fails, some other don't. Boot sequence is given in the datasheet. It is, again, specific to the family. \$\endgroup\$ – Oleg Mazurov Feb 1 '15 at 17:20
  • \$\begingroup\$ How is this not directly and clearly answered in the datasheet? \$\endgroup\$ – Olin Lathrop Feb 1 '15 at 18:59
  • \$\begingroup\$ @OlinLathrop Datasheet? TL;DR ... ;) \$\endgroup\$ – brhans Feb 2 '15 at 3:59
2
\$\begingroup\$

PIC don't really have "boot sequences", since that's a software abstraction and there is no standard software that runs on a PIC, like a bios on a PC. PIC are generally programmed with code that performs a dedicated task, usually without a operating system. The code is stored in the same non-volatile memory it is executed from (except some PIC 32s can be set up to execute from RAM), so there is nothing to "boot".

The diferrent PIC architectures vary a bit in what happens on powerup or after a reset, but mostly execution just starts at a single known address. The start of your code has to be at that address.

As for configuration settings that have to be made before any code can execute, like the oscillator selection, these are stored in the configuration bits. These are special non-volatile bits that are used directly by the hardware.

This is, of course, all described in detail in the datasheet or family reference manual.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Could you explain how the config bits are used? As in when the system powers up, what circuitry is responsible for reading and setting those values. \$\endgroup\$ – AlanZ2223 Feb 1 '15 at 19:20
  • \$\begingroup\$ The oscillator circuitry directly reads those bits. On most PICs, they are written only in programming mode. \$\endgroup\$ – Wouter van Ooijen Feb 1 '15 at 19:23
2
\$\begingroup\$

The boot sequence of a PIC is:

  1. Start executing the code at the reset vector.

That's it.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

For every architecture is basically the same. It starts whichever oscillator you configured with fuses, counts say a 1000 stable cycles and vectors to start location (this is usually location 0 in flash).

From then on it vectors to the startup, which more or less just initialises the ram variables and after that is done it vectors to your main() function.

From then on your SW starts running.

Which PIC family?

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.