Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

subroutine for 5s time out ,use timer 1 - PIC12F1822

Status
Not open for further replies.

poojapatel2210

New Member
****************************************
;routine to set 5S time out, use Timer 1
;****************************************
Tout5SOn:
movlw 0x67
movwf TMR1H
movlw 0x6A
movwf TMR1L
goto SetToutTMR
movwf TMR1L

SetToutTMR:
call SetBank1
bcf PIE1,TMR1IE ;disable TMR1 int
call SetBank0

movlw b'00110100'
movwf T1CON
bsf T1CON,TMR1ON ;turn on timer 1
 

Attachments

  • subroutines.txt
    3.5 KB · Views: 274
hey can u explain how this subroutine works i mean what do they actually do by executing this routine i have attached the full note of subroutine if u want to go through that prof wants me to explain that with some real life senerio.
 
We just went through TMR0 with you (https://www.electro-tech-online.com/threads/how-delay-for-1-sec-works-here.146232/). TMR1 is 16-bit. It counts to 65535 before rolling over (or setting an interrupt). Have you studied interrupts?

My suggestion is for you to flow chart the routine in your own words. Then you might see how it works. I use the free version of Lucid Chart (https://www.lucidchart.com/documents#docs?folder_id=home&browser=icon&sort=saved-desc), but there are lots of ways to do it and other free programs, including almost-free pencil and paper.

John
 
how do i relate this subroutine in real life , suppose i use a push button to perform different funtionality at different timeout does that work.
Can u suggest good link or book to study interupts for beginners. thank you for help
 
As for tutorials, I just used the datasheet(s) that Microchip provides. There are general tutorials that include interrupts:

https://www.gooligum.com.au/PIC-Tutorials

The first is by Nigel Goodwin, who is a long time member and moderator here. The second is also popular, but its author has started charging except for the entry level versions.

As for practical uses for delays, there are just too many to try to list. For a very long delay, such as 5 s, one use might be a sensor that detects when everyone has exited a room and then turns out the lights after 5 s or a seat belt warning after your car is put into "drive" when your seat belt is not buckled.

John
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top