Programming TMR0 Interrupt in PICBasic


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    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

  2. #2
    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.

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


    Did you find this post helpful? Yes | No

    Smile

    (In response to a PM from the OP.)

    For Multiplexing LEDs, I like the refresh rate to be at least 40 Hz or higher. Some use lower but 40+ Hz is rather safe (“normal intensity”red LED flicker fusion frequency in the normal human eye is in the mid 30s). You can chose to multiplex each segment or each digit – most multiplex each digit because it is easier to do and gives more brightness options. For six 7 segment displays, this means your display refresh rate must be 6*40 = 240 Hz minimum. With a 4.000MHz Xtal, my choice would be 244.14 Hz for the refresh rate. This gives 4096 uS per required refresh. 4096 = 256 * 16, which works out well for TMR0 use (use prescale of 16). You can poll the overflow or set up the interrupts. My clock routines noted above can be adjusted around this prescale as well.

    Six displays will require 8 pins for the segments (usually an entire port) (seven if you do not need the decimal point) and 6 lines for the anodes. With this approach, you just update each 7-segment display in turn and all six will look lite.

    Some people like to drive displays like yours with drivers. The MAX7219 is really common for this and works great. You also can buy serial LED clock displays. Bruce (big contributer here) at www.rentron.com sells what looks like a nice one (it was featured in Nuts and Volts not too long back).

    Lastly, Les Johnson's book “Experimenting with PicBasic Pro” (or some title like that) has a worked out example of multiplexing 7-segment LEDs. I hope this helps and respond if you want more.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4
    Join Date
    Mar 2006
    Location
    INDIA
    Posts
    89


    Did you find this post helpful? Yes | No

    Default

    hi emavil, You can understand in simple way how interrupt usein picbasic pro. read this

    http://www.precision.net.in/picbasic/PIC_INT.PDF
    Last edited by precision; - 12th September 2006 at 04:18.

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