Showing posts with label Methods. Show all posts
Showing posts with label Methods. Show all posts

April 13, 2012

Pic Micro Hardware Programming Methods

There are three ways to program a Pic microcontroller

  1. Using general programming hardware (high volt programming Hvp).
  2. Low volt programming (Lvp).
  3. Bootloading.

The first two methods use the programming port of the Pic microcontroller labeled Icsp (In Circuit Serial Programming).




This port is shared between the existing pins of the microcontroller and after programming the pins revert back to general microcontroller operation.

Note: To make Icsp work correctly you have to think the effects and requirements of the Icsp programmer e.g. For Hvp a high voltage exists at the Vpp pin (your circuit must be able to handle the high voltage - up to 13V). Also the loading for the other signals Pgc and Pgd must not be too high i.e. Don't put an Led on these pins that uses 20mA - if you did the voltage levels would not be high enough at the inputs to the Pic for programming.

It's fairly easy to institute for Icsp use by using isolation resistors to general circuitry and choosing not to use heavy loads on these pins.

Icsp provides 6 connections from the pic Icsp programmer to your board as follows :

Vpp - (or Mclrn) Programming voltage (usually 13V).

Vcc - Power (usually 5V).

Gnd Ground (zero volts).

Pgd - Data usual port and connection Rb7.

Pgc - Clock usual port and connection Rb6.

Pgm - Lvp enable usual port and connection Rb3/Rb4.

Pic Micro: High Volt Programming

To use the first formula a hardware interface is needed or 'Pic programmer' to interface between the programming software (usually running on the Pc) and the Pic chip. This hardware takes its facts from the Pc via one of three interfaces either:

  • The Rs232 Com port
  • The Parallel port
  • The Usb port

You select the interface you want to use and then select an standard Pic programmer. The Pc then communicates with the hardware generating the serial (Icsp) signals to translate the Pic hex file into a serial data stream convenient for the target microcontroller.

Note: practically all Pic microcontrollers use the Icsp interface so once you have a Hvp you can program virtually any Pic microcontroller. E.g. You can program 12F675, 16F84, 16F88, 16F877(A), 18F2550, 18F452 etc.

There are several programs for programming Pic micos e.g. Icprog and many different hardware programmers.

Pic Micro: Low volt programming (Lvp)

Lvp is exactly the same as Hvp except:

  • The Vpp voltage is set to the general provide voltage.
  • The Pgm pin indicates programming mode.

Note: In this mode you can not use the Pgm pin for whatever else it is dedicated solely to Lvp control.

Devices are man-made with Pgm mode enabled and the only way to turn off the Pgm mode is to program it using an Hvp programmer.

Note: Some Pic microcontrollers can only use the Hvp formula since for the Lvp formula you have to sacrifice one pin - Pgm - (to tell the Pic Micro whether that it is being programmed (high volts e.g. 5V) or that it is not being programmed (0V) ) and some Pic micros only have 8 pins e.g. 12F675. For this chip the Pgm pin is not available so Hvp is the only way.

The real advantage of using the Lvp mode is that you can program several Pic Micros on a board without having to individually program each one - you could daisy chain each extra micro to a scholar micro which would then program each one in turn - and this is only potential since the Vpp signal is a general logic level in Lvp mode.

Pic Micro: Bootloading

Bootloading uses any available interface to load a program into program memory. It requires a bootstrap program to elucidate the interface data and translate it into program memory instructions.

Note: Note only the newer devices that are capable of programming their own memory can use this method.

Typically a serial port is used for bootloading and the Pic micro bootstrap program will wait for a set time after power up listening on the serial port for a reserved word that tells the bootstrap program to start i.e. It listens for sequence of characters that is not commonly used on the interface

Once it receives this sequence it enters bootstrap mode where a hex file is transmitted to the microcontroller over the interface. It interprets this and programs the memory of the microcontroller and then starts the program.

There are two issues with this method:

  1. You have to program the bootstrap code using Hvp or Lvp.
  2. It uses up some of the microcontroller resources.

Once programed it provides a convenient way of using the expedient as you won't need programming hardware anymore and one major advantage is that you can re-program a expedient without undoing the equipment e.g. If you boxed up you task you could still re-program it using the serial port!

You can find more facts from the website here and how to build a website like it here.

Pic Micro Hardware Programming Methods

FHA Loan to Value Limits Wireless Internet Camera Surveillance

March 28, 2012

Methods for Debugging Microcontroller Hardware

Most of these debugging techniques can be applied to any microcontroller since they do not use any specific tools.

General debugging methods

There are many ways to debug hardware:




  • Ice.
  • Icd.
  • Simulation.
  • Serial Rs232.
  • Lcd.
  • Led.
  • Hardware pins.
  • Logic Analyzer.

Ice

The In Circuit Emulator is the most expensive way to debug your hardware. You buy a extra processor that physically takes the place of the normal processor. This extra processor allows software access to the internal carrying out of the processor (you can set breakpoints on hardware modules).

Icd (Pic microcontroller)

The next best thing to Ice is Icd (In Circuit Debug) Sometimes known as (Bdm - Background Debug Mode - for non Pic microcontrollers) let you singular step straight through code undoubtedly running in the target processor.

For Icd the processor has a small estimate of built in hardware that can halt the processor when the program reaches a specific address. The software can then read back all the registers and processor state.

Simulation

With a source code simulator you can step straight through the high level language code and see its follow on memory and variables without having to look at the collector code directly. This lets you focus on the high level language carrying out and lets you combine on the question you are trying to solve.

One great advantage of the simulator is that you do not have to wait to download and program the target processor (you do have to re-compile the code after changing its source code though). So you can cut out the time enchanting programming task just by using the simulator.

Note: Simulators are no good for debugging interrupts.

Debugging using hardware

Serial Rs232

Newer microcontrollers have a built in Uart giving you a virtually free debug tool that uses minimal resources and needs very small software coding.

For debug output you need to join together the Uart output pin (Tx) to a favorable level translator circuit e.g. A Max232 chip. You may even get away with direct connection (via a resistor) to the input of your Pc serial port (but this depends on the specifics of your Pc hardware) - using a translator chip will always work.

Advantages

  • Minimal coding.
  • Simple to use.
  • Minimal extra hardware.

Disadvantages

  • Takes a long time to output a character (~1ms).
  • Takes even longer for blocks of characters (~10s of ms).
  • Needs extra hardware.

Even straight through it takes time to output a character it is a beneficial debug tool as you can output the value of a variable to see what the microcontroller is undoubtedly doing.

Lcd

An Lcd (Liquid Crystal Display) gives a favorable way of displaying debugging information. It is also beneficial for many separate applications that need a text display output.

It is a module that displays text characters and a coarse screen size is 2 rows of 16 characters.

Most Lcd modules use the Hd44780 controller chip which is why Lcd routines built into high level languages always work.

Advantages

  • Very quick update (40us 4 bit data bus).
  • Useful in many projects as the main display interface.
  • Simple to interface to an 8 bit port (only needs six of the 8 bits).

Disadvantages

  • Uses up an 8 bit port.
  • Hardware is more expensive (e.g. Compared to a serial port chip).

Led

Using an Led as a microcontroller 'alive' indicator.

Even though it is such a simple thing to blink an Led on and off it is very beneficial as a debugging tool as you can tell at a look whether the code you just downloaded is working.

Sometimes you can will incorrectly set parameters on the programming software or compiler which will stop the code dead.

The Led indicator gives a quick health check for your microcontroller which is easy to see.

Pin Debugging

This is the simplest and crudest debugging method; using any ready port pin. Plainly set or reset this pin at any point in the code that you want to monitor.

It has minimal impact on the code speed or size and can give you the following information:

  • You can tell if the code is active.
  • It gives you the repetition rate.
  • It gives you the routine time length (if you set the pin at the start and reset it at the end).

Note: To do testing you need an oscilloscope or a frequency counter and time interval measuring tool.

Logic Analyzer

This tool attaches to the pins you want to survey and captures the waveforms displaying multiple traces on a singular display. It uses a trigger module that can be set to begin on combinations of the input signals or on their length. So you can trigger on specific patterns or on glitches or both.

For non-microcontroller based systems (e.g. 80486 based) where the data and address bus are exposed a logic analyzer can show the address and data organized into hex words i.e. Readable. Some can disassemble the instructions showing what the processor was doing at the trigger point.

For a microcontroller based principles the logic analyzer can be beneficial in examining peripheral carrying out e.g. For debugging the Spi or I2C busses some logic analyzers also have built in withhold for these protocols.

Another use for the logic analyzer is to capture output over a long period of time depending on the memory capacity of the logic analyzer.

Summary

In short there are many techniques to debug your hardware ranging from simple (an output pin) to involved (a logic analyzer). All of them can be beneficial depending on the question you want to solve.

You can find more data here and how to build a website like it here.

Methods for Debugging Microcontroller Hardware

Car AC Compressor Troubleshooting USB Cable Adapter iPhone S.S.C. Napoli News Blog