1 / 7

EEE305 Microcontroller Systems

Lecture 5B: Simple I/O Embedded C using PIC microcontrollers Teaching resources on on www.eej.ulst.ac.uk My office 5B18, telephone 028 90 366364 My email IJ.McCrum@ulster.ac.uk. EEE305 Microcontroller Systems. Switches.

sonja
Download Presentation

EEE305 Microcontroller Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 5B: Simple I/O Embedded C using PIC microcontrollers Teaching resources on onwww.eej.ulst.ac.uk My office 5B18, telephone 028 90 366364 My email IJ.McCrum@ulster.ac.uk EEE305 Microcontroller Systems http://www.eej.ulst.ac.uk/~ian/modules/EEE305

  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}

  5. 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

  6. Now need to study interrupts – we will revisit timers…

More Related