Presentation is loading. Please wait.

Presentation is loading. Please wait.

PIC Discussion By: Eng. Tamar Jomaa.

Similar presentations


Presentation on theme: "PIC Discussion By: Eng. Tamar Jomaa."— Presentation transcript:

1 PIC Discussion By: Eng. Tamar Jomaa

2 C programming-part2 Outlines: 7-Segment EEPROM Timers Interrupt
Lab#9:Application to Interrupt

3 7-Segment One press on RB0 automatic counter from 0 to 9 (increment by 1) One press on RB1 automatic counter from 0 to 9 (even numbers) One press on RB2 automatic counter from 0 to 9 (odd numbers) Example#1

4 7-Segment Solution: Example#1

5 Example#1 EEPROM Write 0x10 in address 0x5. In Micro C:
EEPROM_write(address,data) EEPROM_read(address) Write 0x10 in address 0x5. Example#1

6 EEPROM Solution: Example#1

7 EEPROM Fill all EEPROM locations with 0x55. Example#2

8 EEPROM Write 0x07 in address 0x05, then read data from address 0x05 to portB . Example#3

9 EEPROM Program to take the data existed on PORT A and display it on PORT B: first, the data must be taken from PORT A and stored in the EEPROM address location 0X10, and then be taken again from EEPROM and be displayed on PORT B. Example#4

10 EEPROM Solution: Example#4

11 Timers PIC16f84A PIC16f877A

12 Timers

13 Timers Display the value of TMR0 in portB. Example#1

14 Example#1 Timers Solution: External clock source on RA4
PSA=1, so tmr0 will count 1:1

15 Example#1 Timers another Solution: External clock source on RA4
PSA=0, so tmr0 will count according to prescale 001≡ 1:4 increase by one ever 4 clocks.

16 Example#1 Timers another Solution: internal clock source as oscillator
PSA=0, so tmr0 will count according to prescale 000≡ 1:2 increase by one ever 2 clocks.

17 Interrupt Connect 4 LEDs to bins (RA0,RA1,RA2 and RA3) of portA, and then toggle these LEDs using the interrupt on(RB4-RB7), so that RB4 controls RA0, RB5 controls RA1 and so on. Example#1

18 Interrupt Example#1

19 Interrupt Flasher on RA0 then use the interrupt method to control the flashing speed. Use interrupt on change RB. Example#2

20 Interrupt Example#2

21 Example#3 Interrupt If RB4 is pressed the counter will count F,E,D,….0
If RB4 is pressed the counter will count A,9,8,…..0 If RB6 is pressed the counter will count 5,4,3,…..0 The default counting from: 70 Example#3

22 Interrupt Example#3

23 Example#4 Interrupt PortB= value of TMR0
PSA=111  TMR0 increase by one every 256 push on RA4 If TMR0 goes from FF to 00 Interrupt occurs and RA0 toggle. Example#4

24 Interrupt Example#4

25 Application to Interrupt
Lab#9: Application to Interrupt If the crier (muezzen) after doing the athan pushes the button related to that athan, two seven segments will decrease from (25,20,10 or 5 minutes) according to the pray time, and when they reach zero then the iqama time comes. LED will flashing indicating that the crier (muezzen) must do the iqama now. The buttons will be connected on bins (RB4, RB5, Rb6 and RB7) respectively, and will be accessed using interrupt method. Iqama project Iqama project

26 Application to Interrupt
Lab#9: Application to Interrupt Iqama project

27 Application to Interrupt
Lab#9: Application to Interrupt Iqama project

28 Application to Interrupt
Lab#9: Application to Interrupt Modified Iqama project by adding another push button for the Fajer. When the program finish display 25 in the two 7segments as flasher. (5 marks) Iqama project

29 Application to Interrupt
Lab#9: Application to Interrupt Do the modified Iqama project software and hardware. Attach the CD for the MicroC code and simulation and send to me hard copy report. Only 3 students in every group. Iqama project

30 Be free to ask any question.
Eng. Tamar Jomaa 29/07/1438


Download ppt "PIC Discussion By: Eng. Tamar Jomaa."

Similar presentations


Ads by Google