Download presentation
Presentation is loading. Please wait.
Published byBerniece Rogers Modified over 9 years ago
1
EEE305 Microcontroller Systems Lecture 5B: Simple I/O Embedded C using PIC microcontrollers Teaching resources on on www.eej.ulst.ac.ukwww.eej.ulst.ac.uk My office 5B18, telephone 028 90 366364 My email IJ.McCrum@ulster.ac.uk http://www.eej.ulst.ac.uk/~ian/modules/EEE305 1/
2
Switches You can wire a switch up to an input pin, and put the other end of the switch to ground. You need a pullup pin from the port pin to Vdd then to bias the pin high when the switch is not closed. The pullup can be external or internal (PORTB only). You can also wire a switch up between an input pin and Vdd, in which case you need a pulldown resistor between ground and the pin. How do you read 16 switches? Either by wiring them up to a shift register and using 2 or 3 pins to clock the data in serially (see 74HC165 as a suitable chip) or use a multiplexing approach to save pins. Cheap but more complex software
3
7 Segment displays To drive a seven segment display needs 7 output lines, or 8 to display decimal point To drive 4 displays could use 28 or 32 pins. Common to either use a hardware shift register or a seven segment display controller chip (allows brightness control and flashing) Or to multiplex pins, 7 to drive the segments and 4 to select which digit is active. The human eye has persistence of vision so if a display is “on” for 10 out of every 40 msecs it thinks it is on all the time – albeit at 25% brightness. In practice you can exceed the LED continous current limit by a factor of 4 and restore the brightness levels.
4
Diagram of multiplexed 7-seg 4 digit display Every 10 milliseconds output a pattern from {0001,0010,0100 and 1000}
6
Resources of the millenium board PORTA, analog input ch0-2 & LCD (3) PORTB, 2 bits set aside for programmer – 6 spare use 4 for digit select/keypad row o/p(RB0-3) PORTC, 2 bits set aside for serial comms to PC – 6 spare, bring in 4 columns from keypad (RC0-3) PORTD all 8 spare – drive 7 segments a-g, dp PORTE 3 spare – use for LCD Leaves RC4,RC5,RB4,RB5 and maybe RA1,2 free
7
Resources of the Mikroelectronic EasyPIC V7 Loads of LEDs and Switches, you need to set various switches – see Page 22 and 23 of the manual 4 digit 7-seg display – PORTD & RA0-RA3 use ‘0001’ to select, see page 27 of manual ADC, e.g the variable potentiometer P1 can be connected to RA5 – nb add jumper on J15, see Page 30 of manual Buzzer, page 32, jumper J21 e.g to use RE1 UART link to PC – via USB and FTDI convertor, nb plug into the lefthand side and ensure J3 and J4 link RX and TX to FTDI. Also switch SW1 and SW2 to connect RX and TX to RC7 and RC6 – Page 16 of manual.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.