Programming TMR0 Interrupt in PICBasic


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Posts
    31

    Question Programming TMR0 Interrupt in PICBasic

    Hi. I really had a hard time understanding the TMR0 interrupt of PIC16F84A (4MHz crystal). I'm using PICBasic. Is there anyone who could give just a simple demonstration on how to program interrupts, including the prescaler configurations. I'm building a simple digital clock with 6 multiplexed CA 7-segment displays, with 3 buttons. I'm very much curious about the accuracy of the clock, especially the 1 second generation. What is the right refresh rate of the 7-segments? Which part of the program do I have to process the incrementing of seconds, minutes & hours?

  2. #2
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    I can't say much about the PIC side of the question, since I'm new to them (or they're new to me), but, assuming you're talking about multiplexing 6 separate 7-segment LED displays (and assuming I understood your question correctly), I think you need to refresh them at about 30 Hz.

    Russ

  3. #3
    ra68gi's Avatar
    ra68gi Guest


    Did you find this post helpful? Yes | No

    Default

    Hi ,
    I have done a similar RTC with 89c2051 microcontroller using BASCOM compiler. Its a basic compiler for the 8051 core. The clk will display seconds minutes and hours on 6 seven segment display, which are multiplixed and i have not used any driver/ latch ics. I have used timer0 in mode2( 8 bit auto reload). i have also provided 2 switches to set hours and minutes.
    If you are interested let me know.
    Free Demo version of bascom is available with which you can write upto 2k code. The clk program took around 1300 words if i remember it right.
    Raghunathan

  4. #4
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Although it does not use LEDs, I posted clock code that keeps excellent time (without the need for a RTC) based on TMRO here

    http://www.picbasic.co.uk/forum/showthread.php?t=2129

    You could use the time keeping part of the code for your clock time and change the display updates as required for your LED display. Reply back if you need more information.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Display Example, to drive LED displays

    For the display part, I would like to make a suggestion.

    Since you will need to drive say PORTB with a HEX number to display a digit on the LED display, I would recommend storing HEX values in EEPROM.


    Code:
    EEPROM 0,[$c0,$F9,$A4,$B0,$99,$92,$82,$F8,$80,$90]
    
    
    Incoming = 5 
    'from 0 to 9
    
    
    READ Incoming, PORTB

    So that you won't need to use a lookup table.


    '==Display Configuration==

    A PORTB.0
    B PORTB.1
    C PORTB.2
    D PORTB.3
    E PORTB.4
    F PORTB.5
    G PORTB.6
    Dt PORTB.7

    'NUMBER - HEX on Portb
    'high pin turns off the led.
    'low pin turns on the led.

    0= $c0
    1= $F9
    2= $A4
    3= $B0
    4= $99
    5= $92
    6= $82
    7= $F8
    8= $80
    9= $90
    -= $BF
    C= $C6




    - This configuration was for 4x7 Segment LED display.


    ________________________--
    Last edited by sayzer; - 6th September 2006 at 19:22.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  3. TMR0 interrupt and HSERIN
    By boban in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd September 2008, 11:48
  4. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 15:10
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts