160 likes | 812 Views
2. PIC course ? PICs and MPLAB. Programmable Interface Controllers (PICs)Why PICs ?Cheap, programmable devicesLarge variety I/O options.- Plus advanced I/O - USB, Ethernet, Manufactured by Microchip, www.microchip.com . 3. PIC course ? PICs and MPLAB. A few flavours:Low-end devices: (12-bit
E N D
1. 1 PIC course Program design - Assignment hand-out
Microchip – PICs and MPLAB
3) Input and Output – Digital and serial I/O
4) Debugging – using MPLAB simulator
5) Lab session
6) Analogue input
7) Interrupt programming – external and timers
8) Simulator - stimulus and DCMI
9) Test 2 – Assignment hand-in
2. 2 PIC course – PICs and MPLAB Programmable Interface Controllers (PICs)
Why PICs ?
Cheap, programmable devices
Large variety I/O options.
- Plus advanced I/O - USB, Ethernet,
Manufactured by Microchip, www.microchip.com
3. 3 PIC course – PICs and MPLAB A few flavours:
Low-end devices: (12-bit instruction size) – e.g. PIC16C5X
Mid-range devices (14-bit instruction size)
High(er)-end devices: (16-bit instruction size) – PIC18 range – we’ll use the PIC18C452
Top-end devices: (16-bit instruction and data word) – PIC24
4. 4 PIC course – PICs and MPLAB 18C452 Features:
Operating voltage Standard: 4.5 - 5.5V, L parts: 2 – 6V
Frequency DC – 40MHz
Oscillator Crystal, external RC
Program memory (bytes) 32K
Data Memory (Bytes) 1536
I/O Ports 5 – Ports A, B, C, D, E
Timers 4
Capture/Compare/PWM 2
Serial Communications MSSP, USART
Parallel Communications PSP
10-bit Analog-to-Digital Module 8 input channels
Programming In-circuit serial, or programmer
5. 5 PIC course – PICs and MPLAB Pin-out – note multi-function pins
6. 6 PIC course – PICs and MPLAB Circuit – simple – Clock: RC or crystal
7. 7 PIC course – PICs and MPLAB PIC registers
PIC is controlled by Special Function Registers (SFR)
I/O ports: TRIS (tri-state control register)
– TRISA for PORTA, TRISB for PORTB etc.
A ‘0’ sets pin as output - a ‘1’ sets it as input.
Other SFRs, e.g:
Analogue, timer, control and capture register
Programming: SFRs defined in .H header file.
8. 8 PIC course – PICs and MPLAB PIC configuration register
Holds design set-up
e.g oscillator type (RC, crystal) and speed,
watch dog timer, brown out & low voltage detect levels etc.
Is controlled by a fuse, set when PIC programmed
If relevant, have to set in code – e.g:
#pragma config WDT = OFF
9. 9 PIC course – PICs and MPLAB C Programming
ANSI – slightly different from C#
(no Console reads or write)
- No Op Sys or pre-written I/O with embedded systems
Microchip MCC18 compiler
MPLAB program debugger environment
Free from Microchip – see notes
10. 10 PIC course – PICs and MPLAB Program is compiled, linked (with other programs) and run under MPLAB.
MPLAB does have serial output emulator
This week’s task
First program writes to this.
11. 11 PIC course – PICs and MPLAB First program:
//
// Hello.c - prints Hello world ! - jba 6/09
//
#include <stdio.h> // includes the printf definition
#pragma config WDT = OFF
// command to C18 - turn off the watch-dog timer - later
void main (void) // main program starts here
{
printf ("Hello World !"); // print to MPLAB output window
while (1) ; // permanent loop to end prog.
}
12. 12 PIC course – PICs and MPLAB Other embedded processors
ARM processors
The ARM (Advanced RISC Machine)
32-bit architecture
Used in PDAs, iPODs and mobile phones. There are many variants but they all use the same processor core.
C compilers are available for these.
13. 13 PIC course – PICs and MPLAB Other embedded processors
Arduino board
Uses Atmel ATMega 32 bit processor
Programmed via USB port
Expanded using plug-in modules
14. 14 PIC course – PICs and MPLAB Summary
PIC devices
Features
Pin-out
Hardware design
SFRs
MCC18 & MPLAB
First program
Other embedded processors
15. 15 PIC course – PICs and MPLAB This week’s task
Type in ‘Hello World’ program
Run MPLAB – set up environment (PIC, add C program and link to PIC library and header files, set Memory model)
Set output window to simulate serial I/O
Run program
Output: