Involving Config Bits in Microcontroller Based Projects

Microcontrollers will quite often be devoted to a specific reason, so while they're truly adaptable gadgets nowadays, there are various unique (frequently clashing) choices for how you could need the equipment to work. You could believe that this configuration is done in programming, however imagine a scenario where you need the equipment to act a specific way from the very beginning. Remembering that Microchip PIC gadgets would be able "boot" in a question of milliseconds, there should be a way you advising the equipment how to act ahead of it firing up. This article covers how to get your microcontroller based project working the manner in which you expect when it fires up.


Enter config bits, or, as they used to be called, config wires. Once upon a time when microcontrollers were program-once gadgets, you truly blew a wire to program them. Today, most micros have streak memory that can be modified huge number of times, yet there are still one-time-programmable (OTP) gadgets about silver bullet 1.1.2.


Regardless, there's a lot of "config words" that characterize how the miniature will act every step of the way. How about we take a gander at a portion of these choices (we'll pick the PIC18F2620 for instance) and afterward perceive how to program them. Sourceboost gives you all the config strings in a prepared to-involve design for remembering for your task. The arrangement has the config bits suffixed with a similar name as the config word so you can guarantee that the right pieces are going in the right word. Obviously, your config words will be unique assuming you're utilizing an alternate microcontroller, however you ought to learn enough here to point you in the correct heading.


In the 18F2620, the config pieces are put away in streak, yet at a high memory area. They're put away at 0x300001 and upwards. For recorded reasons because of the manner in which memory was recently organized on PIC microcontrollers, config words are numbered with each number having a "high" and "low" byte.


There is no such thing as config1l on the 18F2620. Assuming that it did, it would inhabit 0x300000 area.


CONFIG1H contains bits that determine oscillator choices. For the most part, in Embedded Adventures projects we attempt and utilize outside precious stones which give more exact and solid outcomes. This utilizations up two pins in any case, and at times these can be a higher priority than the speed at which the chip is running. The outside precious stone oscillator is alluded to as the HS oscillator (in the event that you're doing the run of the mill thing of attempting to run the miniature as quick as it will go). In the 18F2620, you can likewise empower the PLL module which will give you a four-times speed help. From CONFIG1H are additionally choices to empower the safeguard clock screen (that changes to the inside oscillator should the outside one come up short, and a choice to empower the exchanging between various oscillator sources.


We for the most part suggest that you utilize an outside precious stone, and mood killer any oscillator exchanging/failover modes. In prototyping, it is essential to have solid, repeatable outcomes (for the most part so you can decrease the tomahawks of blunder). It is feasible to configure the 18F2620 to fire up utilizing the inward oscillator (which runs at 8Mhz, or 32Mhz with the PLL empowered) and afterward change to the outer one (we utilize a 10Mhz gem with PLL empowered giving you 40Mhz). That gives you quicker startup from hinders in rest mode or on bootup, assuming that is significant, but for prototyping, this is for the most part excessive.


Our suggested config string for CONFIG1H:


#pragma DATA _CONFIG1H, _OSC_HSPLL_1H and _IESO_OFF_1H and _FCMEN_OFF_1H


CONFIG2L handles brown-out reset and the enhancer clock. Brown Out Reset (or BOR) is simply the capacity for the microcontroller to reset itself in the event that the inventory voltage falls under a predetermined limit. It will stay in reset state until the stockpile revisits the edge. This can mean some battery saving (at any rate, when the battery is level past a specific level, it'll quit depleting power as fast) - however by then there's no usefulness accessible in any case. The power on clock looks out for starting power-on for the inventory to go over the BOR voltage limit, then, at that point, sticks around for another 65ms prior to starting things off without a doubt. This can assist with guaranteeing that your power supply is consistent prior to attempting to execute any code.


We have seen a few pretty erratic outcomes from the 18F2620 while testing some LED show boards. We thought the product was crashing or resetting the miniature when indeed, what was occurring was the BOR was being stumbled as more LEDs were lit and the power supply dropped. Accordingly, except if you have a genuine requirement for it, we suggest turning it off. Leaving the power supply to settle prior to beginning the firmware, is for the most part really smart (you're presumably not going to see the 65ms it takes).