PIC16F84A using pulsout and TMR0


Closed Thread
Results 1 to 33 of 33

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    you could save it to the codespace and play around the following
    http://www.pbpgroup.com/modules/wfse...p?articleid=10

    or, use an external EEPROM.
    Steve

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

  2. #2
    Join Date
    Nov 2006
    Posts
    33


    Did you find this post helpful? Yes | No

    Post LCD question

    Hi all
    Thanks for the reply.

    Just now on the lab I have try to display the word in the LCD but NOT SUCCESS.
    Below is the code I follow all the connection on the PBP manual using PIC16F84A. LCD is bought from the www.cct.com.my.


    ‘ Set LCD Data port
    DEFINE LCD_DREG PORTA
    ‘ Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_DBIT 0
    ‘ Set LCD Register Select port
    DEFINE LCD_RSREG PORTA
    ‘ Set LCD Register Select bit
    DEFINE LCD_RSBIT 4
    ‘ Set LCD Enable port
    DEFINE LCD_EREG PORTB
    ‘ Set LCD Enable bit
    DEFINE LCD_EBIT 3
    ‘ Set LCD bus size (4 or 8 bits)
    DEFINE LCD_BITS 4
    ‘ Set number of lines on LCD
    DEFINE LCD_LINES 2
    ‘ Set command delay time in us
    DEFINE LCD_COMMANDUS 2000
    ‘ Set data delay time in us

    Pause 100 ' Wait for LCD to startup
    LCDOut $fe, 1 ' Clear LCD screen
    LCDOut "Hello" ' Display Hello

    End

    Please advice and thanks

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Double check all connections. Do you have the pullup resistor on RA4?

    /Henrik Olsson.

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


    Did you find this post helpful? Yes | No

    Default

    AND never finsih your program with a single END... use a endless loop or PBP STOP.
    Code:
        LCDOUT $FE,1,"Your stuff"
    Loop:
        Goto Loop
    Steve

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

  5. #5
    Join Date
    Nov 2006
    Posts
    33


    Did you find this post helpful? Yes | No

    Post using 2 interupt

    Hi all,
    Thanks for the reply.

    Regarding the LCD everyting look fine in my circuit. After power on the, the LCD come 16 small black square on the screen but it does not display "Hello".

    Regarding the website that u given to me i'm not very understand. Do you have the simple one and is in the pure PicBasic Pro language. Besides in the website I noticed one things which we can add 2 or more interrupt at the same time..But I go thru this I not really understand.....Thanks

    Below is the statement that provide by the mister_e:-

    ****************too bad PIC16F84a don't have 2 timers... *********
    ************************************************** ******
    I'm planned to use the PIC16F876A there got timer 0 ,1 and 2.

    (1) Is that possible using 2 interrupt in a single program.??

    (i) One interrupt (tmr0) is for the clock pulse to send to the stepper motor driver
    (ii) One interrpt(tmr1) is for the 1 second elapsed.

    If the above possible...Does it mean that in the program I need to have two
    ON INTERRUPT code..

    Please guide me thru this..... Thanks you all very very much........
    Last edited by DragonBall_6; - 5th December 2006 at 10:43.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Basicly you can have as many interrupts sources as the PIC has (TMR0, TMR1, USART, RB0, RBChange, CMP, ADC, whatever.....). When the program interrupts and starts executing the ISR (InterruptServiceRoutine) you need to check what caused the interrupt and act uppon it accordingly.

    My approach to this would be to use an external 32.768kHz xtal, set the TMR of your choise up to generate an interrupt at 100Hz, then in the ISR count those ticks. When you have 100 ticks you have a second. When you have 216 ticks, toggle your step pin.

    Code:
    Ticks var byte             '1/100th seconds
    StepTicks Var Byte      '1/100th seconds, used for step pulse timing
    Seconds var Byte        'Seconds
    Minutes Var Byte         'Minutes
    Hours var Byte            'Hours
    Days var Byte             'Days, perhaps change this to a Word.
    
    Goto Main                  'Jump over ISR.
    
    DISABLE
    
    ISR:
    'Reload timer with correct value here, and restart it.
    
    Ticks = Ticks + 1
    If Ticks = 100 then
      Ticks = 0
      Seconds = Seconds + 1
        If Seconds = 60 then
          Seconds = 0  
            Minutes = Minutes + 1
            If Minutes = 60 then
              Minutes = 0
              Hours = Hours + 1
                If Hours = 24 Then
                  Hours = 0
                  Days = Days + 1
                Endif
            Endif
         Endif
    Endif
    
    StepTicks = StepTicks + 1
    If StepTicks = 216 then        '2.16s, time to toggle the step pin.
      StepTicks = 0
      Toggle StepPin
    Endif
    
    RESUME
    ENABLE
    
    Main:
    
    '---------------------------------------------
    'Your main code here.......
    'remember, NO time consuming commands, like Pause, sleep, nap etc.
    '----------------------------------------------
    Goto Main
    This is completely untested and just something to show you one approach. Also, I suggest you'll have a look at Darrel Taylors Instant Interrupts, search the forum, it makes interrupts a breeze but MAY be overkill in this application.

    About that LCD, if your connections ARE fine and matches your DEFINES then the only thing I can think of is a longer pause at the beginning OR you could try to increase the command and data delay with:
    Code:
    DEFINE LCD_COMMANDUS 2000    '<-----Increase this...
    DEFINE LCD_DATAUS 50             '<----and this.
    /Henrik Olsson.
    Last edited by HenrikOlsson; - 5th December 2006 at 07:42. Reason: Moved ISR to beginning.

Similar Threads

  1. Pin won't stay high during Repeat...Until loop??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th August 2009, 00:57
  2. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 10:00
  3. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 08:12
  4. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 05:52
  5. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 03:35

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