Skip to content

9. Embedded programming

Group assignment:

Compare the performance and development workflows for other architectures.

For this experience we will compare the ATMEGA 328P microcontroller, used in Arduino with the PIC 16F877 microcontroller.

Arduino:

is a free software and hardware development company, as well as an international community that designs and manufactures hardware development boards to build digital devices and interactive devices that can detect and control real-world objects. (Wikipedia).

Features of the ATMEGA 328P microcontroller used in Arduino:

Taking as a reference the manufacturer’s data sheet we summarize the following:

  1. Microcontroller manufactured by the company ATMEL.
  2. High performance, low power AVR 8-bit microcontroller
  3. Advanced RISC architecture
  4. 131 powerful instructions – most single clock cycle execution
  5. Fully static operation
  6. On-chip 2-cycle multiplier
  7. Microcontroller combines 32 KB ISP Flash memory with read-while-write capabilities.
  8. 1024B EEPROM, 2 KB SRAM, 23 general purpose I/O lines, 32 general purpose working registers.
  9. Three flexible timer/counters with compare modes, internal and external interrupts.
  10. Serial programmable USART, a byte-oriented Two-Wire serial interface.
  11. SPI serial port.
  12. 6-channel 10-bit A/D converter (8-channels in TQFP and QFN/MLF packages).
  13. Six PWM channels.
  14. Programmable watchdog timer with internal oscillator, and five software selectable power saving modes.
  15. The device operates between 1.8-5.5 volts.
  16. By executing powerful instructions in a single clock cycle, the device achieves throughputs approaching one MIPS per MHz, balancing power consumption and processing speed.
  17. Speed grade: 0 to 8MHz at 2.7 to 5.5V (automotive temperature range: –40°C to +125°C) 0 to 16MHz at 4.5 to 5.5V (automotive temperature range: –40°C to +125°C).

Block Diagram

Programming Software To start programming the Arduino board it is necessary to download an IDE (Integrated Development Environment). The IDE is a set of software tools that allow programmers to develop and record all the code necessary to make our Arduino work as we want. The Arduino IDE allows us to write, debug, edit and record our program (called “sketches” in the Arduino world) in an extremely simple way, in large part to this is due to the success of Arduino, to its accessibility.

## Microcontrolled system based on el PIC 16f877A:

The family of microcontrollers known as PIC is also manufactured by the company Microchip. The microcontroller chosen for comparison this time is the PIC 16F877A, because it is the one, we have at hand. Characteristics of the microcontroller taking reference to the data sheet. High-Performance RISC CPU: 1. Only 35 single-word instructions to learn 2. All single-cycle instructions except for program branches, which are two-cycle 3. Operating speed: DC – 20 MHz clock input DC – 200 ns instruction cycle 4. Up to 8K x 14 words of Flash Program Memory, Up to 368 x 8 bytes of Data Memory (RAM), Up to 256 x 8 bytes of EEPROM Data Memory. 5. Two Capture, Compare, PWM modules 6. 10-bit, up to 8-channel Analog-to-Digital Converter (A/D). 7. Wide operating voltage range (2.0V to 5.5V).

Programming Software To carry out the programming of the PIC family there are several software, the one we will mention on this occasion is the PIC C COMPILER. It is a software designed for programming PIC microcontrollers. It has a wide variety of PIC devices compatible with the software. Creating a new Project Once the software is installed, to create a new project, go to the top left of the program window, select File, click New and Source File.

It will be displayed to the next window, assign the name of the project and the path in which it will be located. Once configured click on Save.

Once the project is created, the next window will be displayed where you will start writing the code.

Compilation To compile the project, in the top bar go to the compile tab and proceed to compile:

Recording To make the recording of the PIC microcontrollers an external recorder is used where the data is loaded in hexadecimal, this time we will use the commercial recorder of the same company the PIC Kit 2 programmer.

Reflect on your individual page what you learned A microcontroller is a single integrated circuit (IC) that is comparable to a small standalone computer and is designed to perform the specific tasks of embedded systems. A microcontroller contains a processing unit and a small amount of memory (ROM, RAM, etc.), few I/O ports for peripherals, timer, etc. AVR and PIC belong to the family of microcontrollers. The PIC microcontroller and the AVR microcontroller differ from each other in terms of different architecture and different sets of instructions, speed, transmission, memory, power consumption, bus width, etc. Now let’s understand in detail how they differ from each other.

Difference between AVR and PIC:

Individual assignment:

For this experience we will develop the same application both in a microcontroller of the Microchip factory (PIC-16f877) and one of Atmega (AVR-328P). As an application exercise we will use a 16x2 display to present a message ” HELLO FRIENDS “.

1.- Using PIC 16F877

Development of the application program in PIC COMPILER:

Recording the Hexadecimal Code on the microcontroller using the PICKit2 recorder.

2.- Using AVR 328P

Development of the application program in Arduino IDE

Circuit implementation

Personal reflection

What we can rescue from the experience is that both PIC and AVR technology are useful for the development of prototypes and electronic applications, but we can make some comparisons in the programming issue, for example the PIC use a compiler program and another to make the recording, while in AVR it also has its compiler and recorders but this time we are using the ATMEL328 P that can be handled directly with the IDE developed by ARDUINO which facilitates the programming and recording of the microcontroller.


Last update: June 4, 2022