Programming Issues


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2008
    Posts
    30

    Cool Programming Issues

    I am trying to use a timer1 program I created in pic simulator ide with microcode studio plus. I could not figure out the syntax in microcode studio plus for the timers so I made it with pic simulator ide, but I prefer to use microcode studio plus because all my other programs are made with it and I want to stay with the same software. My program works fine in pic simulator but in microcode it does not work here is my code; microcode complains about all the lines in bold.

    TRISB = %10000000
    INTCON = %11000000
    PIE1 = %00000001
    TMR1L = %11011100
    TMR1H = %00001011
    T1CON = %00110001
    PIR1.TMR1IF = 0
    Dim overflow As Byte


    start:

    If PORTB.7 = 1 Then
    PORTB.5 = 1
    Else
    PORTB.5 = 0

    Endif

    Goto start

    End

    On Interrupt

    overflow = overflow + 1

    If overflow = 20 Then
    overflow = 0

    If PORTB.1 = 0 Then
    PORTB.1 = 1 'Turn on LED
    Else
    PORTB.1 = 0 'Turn off LED
    Endif
    Endif

    TMR1L = %11011100
    TMR1H = %00001011
    PIR1.TMR1IF = 0 Resume
    I’ve then changed my program to look like this, it’s like the program never jumps into the blink subroutine does anyone have any ideas why it is not working.

    TRISB = %10000000
    INTCON = %11000000
    PIE1 = %00000001
    TMR1L = %11011100
    TMR1H = %00001011
    T1CON = %00110001
    PIR1.0 = 0

    overflow var Byte

    start:

    If PORTB.7 = 1 Then
    PORTB.5 = 1
    Else
    PORTB.5 = 0
    Endif

    Goto start

    End


    On Interrupt goto blink

    blink:


    overflow = overflow + 1

    If overflow = 20 Then

    overflow = 0

    If PORTB.1 = 0 Then
    PORTB.1 = 1 'Turn on LED
    Else
    PORTB.1 = 0 'Turn off LED
    Endif
    Endif

    TMR1L = %11011100
    TMR1H = %00001011
    PIR1.0 = 0

    Resume

    To me it should be working i have no clue why any help would be appreciated.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    ON INTERRUPT needs to be before start.
    Code:
    TRISB = %10000000 
    INTCON = %11000000 
    PIE1 = %00000001 
    TMR1L = %11011100 
    TMR1H = %00001011 
    T1CON = %00110001 
    PIR1.0 = 0 
    
    overflow var Byte
    
    On Interrupt goto blink ' enable interrupt checking in start
    
    start:
      If PORTB.7 = 1 Then
        PORTB.5 = 1
      Else
        PORTB.5 = 0
      Endif
      Goto start
    
    
      disable ' disable interrupt checking below
    
    blink:
     overflow = overflow + 1
     If overflow = 20 Then
        overflow = 0
    
       If PORTB.1 = 0 Then
          PORTB.1 = 1 'Turn on LED
       Else
          PORTB.1 = 0 'Turn off LED
       Endif
     Endif
    
     TMR1L = %11011100 
     TMR1H = %00001011 
     PIR1.0 = 0 
     Resume 
     enable
    
     END
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Jun 2008
    Posts
    30


    Did you find this post helpful? Yes | No

    Smile TMR1 using picbasic pro

    Thanks bruce il give that a try. Let you know if its worked.

Similar Threads

  1. Data Programming Error at 0000
    By cpatnoi in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd May 2009, 03:37
  2. 16F676 programming problem
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th May 2009, 17:39
  3. Problems programming
    By Lionheart in forum General
    Replies: 4
    Last Post: - 7th December 2008, 16:51
  4. Who can help me checking my Programming
    By slimpeng in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 23rd January 2008, 15:08
  5. Circuit reliability issues
    By hkpatrice in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd November 2007, 14:55

Members who have read this thread : 1

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