Introduction ............................................................................................................................................ 2 Peripheral set-up..................................................................................................................................... 4 Timer1 ................................................................................................................................................. 4 Timer2 ................................................................................................................................................. 4 Discussions .............................................................................................................................................. 5 Task 1; Binary Counter: Counter delay ............................................................................................... 5 Task 2 – LED increment counter using Timer1 as delay...................................................................... 6 Task 3 – Morse code generator .......................................................................................................... 7 Task 4:Writing the group number to the EEPROM ............................................................................. 8 Burglar alarm .................................................................................................................................... 10 Controlling the brightness of an LED using PWM ............................................................................. 12 Conclusion ............................................................................................................................................. 13 References ............................................................................................................................................ 13 Appendices ............................................................................................................................................ 14 Appendix 1- Codes for task 1 ............................................................................................................ 14 Appendix 2-Codes for task 2 ............................................................................................................. 16 Appendix 3-Codes for task 3 ............................................................................................................. 18 Appendix 4-Codes for task 4 ............................................................................................................. 23 Appendix 5-Burglar Alarm ................................................................................................................. 25 Appendix 6-PWM .............................................................................................................................. 28

Introduction

In this coursework, students are introduced to the PIC family of microcontrollers which are becoming common nowadays due to its simplicity to program. Hard-wired circuits can be replaced by microcontroller and its software, thus reducing number of components required. In addition, the software program can be created at minimal cost and it can also be modified to suit different applications. The microcontroller used in this project is the flash-based 8-bit CMOS PIC16F628. The main peripheral features include 16 I/O pins with individual direction control, analog comparator module, 8-bit and 16-bit timer modules, CCP (Capture, Compare, PWM) module, etc. It is programmable using 35 instructions. The features of the PIC16F62X mid-range microcontroller families are shown in Table 1 below.

Table 1: Features of the PIC16F62X mid-range microcontroller families Harvard architecture is used in the PIC16F628 which program and data are accessed from separate memories using separate buses. This saves bandwidth compared to the Von Neumann architecture where program...