Download presentation
Presentation is loading. Please wait.
Published byRosaline Campbell Modified over 8 years ago
1
Microcontrollers JULES CALELLA
2
Microcontrollers vs Microprocessors Microprocessors – do not contain RAM, ROM, I/O Microcontrollers – The whole package (mini computer)
3
Where are Microcontrollers Used? Mouse, toys, phones, game controllers, etc. Anything that requires complex instructions but doesn’t need a full OS
4
How Do You Control a Microcontroller? Programming in C or Assembly C – slower, good starting point for beginners, easy to debug Timing doesn’t work as expected
5
Microchip’s Models 8-bit Start here 16-bit (includes dsPIC) 32-bit
6
Using the Data Sheet Contains everything about the device Summary of modules Pinout Dimensions Registers
7
Errata Sheet Revisions and mistakes
9
Configuration Bits Oscillator Watchdog timer Brown-out reset Every model offers different options
10
Oscillator Controls the timing Internal or external 4MHz, 8MHz (PLL)
11
OSCCON = 0xD2 (1101 0010) OSCCONbits.IRCF = 0x5
12
GPIO TRIS – output (0) or input (1) LAT – Turn ON (1) or OFF (0) PORT – Read ON (1) or OFF (0)
13
Example: TRISA = 0x00; //All are outputs LATAbits.LATA5 = 1; //Turn LED on char pinState = PORTAbits.RA5; //Determine if LED is on
14
ADC Analog-to-digital converter 10 – 14 bit resolution Reference voltage (increase sensitivity) Only some ports have functionality (ANSx) Temperature sensors, light sensors, potentiometers, pressure sensors
15
ANSx = 1 TRISx = 1//Disables digital output driver Left justifiedx x x x x x x x x x _ _ _ _ _ _ Right justified_ _ _ _ _ _ x x x x x x x x x x Time Acquisition
17
Interrupts Practically every module has one Interrupt Flags Priority
18
Timers Hardware based counters with interrupts 8, 16, 32 bit timers Divisible Used as timer or counter
19
void interrupt Timer0_ISR(void) { if (T0IE && T0IF) { T0IF = 0; //Perform some task (e.g. blink LED) //LATA = !LATA; TMR0 = 4; //Depends on how long task takes }
20
Communication UART – slow, 2-wire, asynchronous I2C – faster, 2-wire, synchronous SPI – fastest, 3-4 wires, synchronous Controllable Baud Rate USB – able to communicate with USB hosts
21
Wires for Communication UART – RX & TX I2C – Data & Clock SPI – SS, SCLK, SDO, SDI
22
USB 4 wires (PWR, D+, D-, GND) Host mode and Device mode Internal USB PLL offers higher clock rate Look up and download “Microchip MLA”
23
Peripheral Pin Select Modules multiplexed amongst pins Allows the user to move the modules to desired pin Requires an unlock sequence
24
#include //PRAGMAS //Defines and Global Initializations //Timer Function int main(){ OSCCON = 0x00;//Set up or functions for setup TRISA = 0xF0;//Half input, half output //Don’t forget de-bounce when using buttons while(1) { //Program here } return 0; //You should not reach this point }
25
Debugging For WHEN your program doesn’t run as expected Break points Stopwatch Watch (variables) In-circuit debugging
26
How To Get Started Programmer/debugger (Pickit 3) Starter board (8-bit recommended) Additional microcontrollers IDE (MPLAB X) Compiler (XC or mikroC) Breadboard, LEDs, etc. A book with code examples (optional, but not really…)
28
Final Tips Learn how to display data (LEDs/LCD/computer) Use binary operations Make sure IC’s are shipping from the U.S. Ensure Oscillator works correctly Make small programs to test functions Review Microchip’s tutorial documents Join forums to ask people for help http://electronics.stackexchange.com/ http://www.microchip.com/forums/
29
Thank You Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.