1. 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.
    Dismiss Notice

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

Discussion in 'Homework Help' started by poojapatel2210, Nov 17, 2015.

  1. poojapatel2210

    poojapatel2210 New Member

    Joined:
    Nov 5, 2015
    Messages:
    25
    Likes:
    0
    ****************************************
    ;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
     

    Attached Files:

  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,170
    Likes:
    910
    Location:
    Rochdale UK
    AND????
     
  3. poojapatel2210

    poojapatel2210 New Member

    Joined:
    Nov 5, 2015
    Messages:
    25
    Likes:
    0
    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.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,903
    Likes:
    502
    Location:
    Cleveland, OH, USA

    We just went through TMR0 with you (http://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
     
    • Thanks Thanks x 1
  6. poojapatel2210

    poojapatel2210 New Member

    Joined:
    Nov 5, 2015
    Messages:
    25
    Likes:
    0
    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
     
  7. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,903
    Likes:
    502
    Location:
    Cleveland, OH, USA
    As for tutorials, I just used the datasheet(s) that Microchip provides. There are general tutorials that include interrupts:
    http://www.winpicprog.co.uk/pic_tutorial.htm
    http://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
     
    • Like Like x 1
  8. poojapatel2210

    poojapatel2210 New Member

    Joined:
    Nov 5, 2015
    Messages:
    25
    Likes:
    0
    thank that is helpful i will try to find out more on it
     

Share This Page