Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Odd

    I added the port configuration and acon register configs. That has an effect...
    The bootloader never leaves the bootloader mode to run the user app.

    if I comment out the Hardware configuration section and compile I can load the code via the bootloader, the device disappears from the USB list and then ~10seconds later I get the USB device not recognized.

    I have reloaded the led test program just to make sure the bootloader and chip are still working and they are. Very puzzling, but the registers do seem to have an effect.

    Nothing in the DT_INT writes to EEPROM 0x00? If there is a 5A there then the bootloader thinks its still in boot mode.

    Code:
        LED1   VAR  PORTB.0
        
        DEFINE OSC 20          
        DEFINE RESET_ORG 0x800  
        
        INCLUDE "DT_INTS-18.bas"        ' Base Interrupt System
        INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts                                           
    
        '   Hardware configuration
        '   ======================    
            '
            '   I/O and PORTs
            '   -------------  
        PORTB   =   0
        PORTC   =   0
        PORTD   =   0
        PORTE   =   0
        TRISB   =   %00000000       '<2-1> Inputs
        TRISC   =   0
        TRISA   =   0
        TRISD   =   0
        TRISE   =   0
            '
            '   A/D converter
            '   -------------       
        ADCON0  =   %00000000       ' A/D converter off     
        ADCON1  =   %00001111       ' All Digital Inputs
     '   ADCON2  =   %00000000 
                               
    
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM    
    
    
    
    
    T1CON = $31                ; Prescaler = 8, TMR1ON
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    
    Main:
        Pause 10  
    GOTO Main
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN
    Still puzzled...

  2. #2
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    This hardware config give the same results as the original issue...ie the LED does not blink and the code appears to run off into la la land. Not sure how it is being detected as a usb device with the DT_INTS-18 code.

    Code:
        '   Hardware configuration
        '   ======================    
            '
            '   I/O and PORTs
            '   -------------  
        PORTB   =   0
        PORTC   =   0
        PORTD   =   0
        PORTE   =   0
        TRISB   =   %11111110       '<7:1> Inputs
        TRISC   =   0
        TRISA   =   0
        TRISD   =   0
        TRISE   =   0
            '
            '   A/D converter
            '   -------------       
        ADCON0  =   %00000000       ' A/D converter off     
        ADCON1  =   %00001111       ' All Digital Inputs
        ADCON2  =   %00000000
    I have two port b pins connected together as part of the ICSP and 2 others connected for inputs off a single PB. Setting the TRISB to FE is what got me back to the original problem.

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


    Did you find this post helpful? Yes | No

    Default

    I've never used this loader, but I did take a quick peek at the source files.

    Try this;
    Code:
        DEFINE OSC 20          
        DEFINE RESET_ORG 0x800  
        
        INCLUDE "DT_INTS-18.bas"        ' Base Interrupt System
        INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts                                           
    
        LED1   VAR  PORTB.0
        
    '   Hardware configuration
        '   ====================== 
        ADCON1  =   %00001111       ' All Digital Inputs                         
    
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM    
    
    
    T1CON = $31                ; Prescaler = 8, TMR1ON
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    
    Main:
        Pause 10  
    GOTO Main
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN
    Remove power. Place a jumper from PORTE.0 to ground. Power up & load the above after compiling it.

    After programming it with the loader, power down. Move the jumper on PORTE.0 to Vcc, and power up.

    Does it work now?
    Regards,

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

  4. #4
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Same result

    If I don't have the TRISB config the bootloader never enters the user program mode.

    I added the TRISB = %1111110 and it enters the user program but still shows an undetected USB device after a few seconds and the LED on PORTB.0 is still not blinking.

    One more piece of info, I am getting power from the USB port on my laptop. Even though the user program is not using USB I am "stealing" power for this test setup from the USB port. i.e. I download the program to the bootloader through the PIC USB and leave the cable connected to power the board for testing.

    It doesn't look like anything in the DT_INTS would be triggered from activity on the USB port since I have not explicitly configured the USB_INT. The PIC is certainly seeing a request from the PC since its connected to the PIC circuitry and that could be why I get the USB device not recognized...although I don't get that when i am running just the Blink program using PAUSE 500 statements.

    When I get home later tonight I will load this program directly on the PIC through the ICSP without the bootloader to verify my setup is happy. Then I will try the bootloader again and use an external power supply instead of the USB power.

    ADDED: I have reconfigured the Bootloader to use PORT B.1 instead of Diolan's default of PortE.0. My end application will use Port B.1 so I built this test board assuming portb.1 would work.
    Last edited by vamtbrider; - 25th March 2010 at 21:53. Reason: Added Bootloader Jumper Information

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Try adding ...
    Code:
    DEFINE LOADER_USED 1
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Pheeeewwww! I do NOT like that loader at all.

    I put one together for you here using the Microchip USB HID boot-loader. Give this one a shot. It works 100% with DT_INTS-18.

    I modified the original C18 loader file so you can switch between the external crystal & internal osc at run-time to switch back-and-forth to various speeds.

    Use a 20MHz crystal, 18F4550, and you should have no problems at all with the loader or DT_INTS-18.

    Of course you'll need to download & install the Microchip HID USB loader PC app, but I find that one WAY nicer, and easier to use than the Diolan thing.
    Code:
    '****************************************************************
    '*  Name    : USB_TST.BAS                                       *
    '*  Author  : B. Reynolds                                       *
    '*  Notice  : Copyright (c) 2010 http://www.Rentron.com         *
    '*          : All Rights Reserved                               *
    '*  Date    : 3/25/2010                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : Using the Microchip USB HID Boot-Loader with PBP  *
    '*          : and DT_INTS.                                      *
    '****************************************************************
        
       ' Using the Microchip MCHPFSUSB v2.1 HID USB Bootloader with PBP & DT INTS.
        
       ' Place a 10K pull-up on RB4 with a switch to ground RB4 when pressed. 
        
       ' Loader mode. Press & hold switch on RB4, then press/release reset switch on /MCLR.
       ' Now release switch on RB4.
        
       ' LEDs on PORTD.0 & D.1 will blink on/off quickly showiing you're in loader mode
       ' and the MCHPFSUSB v2.1 HID PC bootloader software should now recognize your board.
        
       ' Open & load your compiled code, with the loader software, then press/release
       ' the switch on /MCLR, or click Reset Device on the loader software.
       
       ' Your code should now be running. 
        
       DEFINE OSC 48                   ' Loader configured for 20MHz OSC on USB board
       DEFINE RESET_ORG 0x1000         ' User code start location for HID loader  
        
       INCLUDE "DT_INTS-18.bas"        ' Base Interrupt System
       INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts                                           
    
       LED1   VAR PORTD.0
       Loops  VAR BYTE
        
       '   Hardware configuration
       '   ====================== 
       ADCON1  =   %00001111       ' All Digital                         
    
    
    ASM
    INT_LIST  macro     ; IntSource,    Label,     Type, ResetFlag?
            INT_Handler  TMR1_INT,  _ToggleLED1,   PBP,   yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM    
    
    
    T1CON = $31                ; Prescaler = 8, TMR1ON
    @ INT_ENABLE  TMR1_INT     ; Enable Timer 1 interrupts
    
       OSCCON = %01110000     ; Switch to internal whenever you want by just
                              ; flipping OSCCON.1 to 1.
                              ; To run at 48MHz, flip OSCCON.1 back to 0..
    Main:
       FOR Loops = 1 TO 6    ' we'll run at 48MHz here
         TOGGLE PORTD.1
         Pause 500
       NEXT Loops
      
       OSCCON.1 = 1          ' we'll run at 8MHz on internal osc here 
       FOR Loops = 1 TO 6
         TOGGLE PORTD.1
         Pause 500
       NEXT Loops
       
       OSCCON.1 = 0          ' flip switch back to 48MHz
       GOTO Main
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
       TOGGLE LED1
    @ INT_RETURN
    
        END
    Some day when I have time I might figure the other one out, but this took a fraction of the time to change & test.
    Attached Files Attached Files
    Regards,

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

  7. #7
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    I think I have two problems.

    One the jumper for bootloader mode is a PB that will tie portb.1 and 2 to ground when pressed. Walking through the bootloader code with the MPLAB debugger the portb inputs are not always on. Some times they are and sometimes they are not. I enabled the pull ups through the INCON2<7> but that doesn't seem to help. So I need to figure that out first.

    A few times I have been able to get the DT_INTS-18 code with the blinky light to load into the PIC via the bootloader while still in debug mode in MPLABS. This has lead to the second problem.

    When the interrupt comes in the code jumps to 0x008 which has a GOTO 0x808.
    At 0x808 is another GOTO 0x998

    running through the interrupt eventually gets to the code below:

    Code:
    1122   08C2    C017             MOVFF usb_sm_state, 0x90               
      1123   08C4    F090             NOP                                    
      1124   08C6    C018             MOVFF usb_sm_ctrl_state, 0x91          
      1125   08C8    F091             NOP                                    
      1126   08CA    C019             MOVFF usb_active_cfg, 0x92             
      1127   08CC    F092             NOP                                    
      1128   08CE    C01A             MOVFF usb_alt_intf, 0x93               
      1129   08D0    F093             NOP                                    
      1130   08D2    8022             BSF [0x22], 0                          
      1131   08D4    B414             BTFSC [0x14], 0x2                      
      1132   08D6    EF74             GOTO 0x8e8                             
      1133   08D8    F004             NOP                                    
      1134   08DA    C021             MOVFF 0x21, PCLATU                     
      1135   08DC    FFFB             NOP                                    
      1136   08DE    C020             MOVFF 0x20, PCLATH                     
      1137   08E0    FFFA             NOP                                    
      1138   08E2    501F             MOVF [0x1f], W                         
      1139   08E4    6AE0             CLRF BSR, ACCESS                       
      1140   08E6    6EF9             MOVWF PCL, ACCESS                      
      1141   08E8    C01E             MOVFF pSrc, PCLATU                     
      1142   08EA    FFFB             NOP                                    
      1143   08EC    C01D             MOVFF 0x1d, PCLATH                     
      1144   08EE    FFFA             NOP                                    
      1145   08F0    501C             MOVF [0x1c], W                         
      1146   08F2    6AE0             CLRF BSR, ACCESS                       
      1147   08F4    6EF9             MOVWF PCL, ACCESS                      
      1148   08F6    0004             CLRWDT                                 
      1149   08F8    A022             BTFSS [0x22], 0                        
      1150   08FA    EFB4             GOTO 0x968
    the program resets after executing the instruction at 08F4 - MOVWF PCL, ACCESS. It looks like the WREG has a value of 0xDC that it is trying to stuff into PCL.

    Basically the debugger stops stepping at that line, I click on the next line below it and select run to cursor the code restarts at 0x00. The bootloader checks the jumper, which is not there and then runs the app.

    So basically it looks like the code keeps running to the first interrupt and then resetting the PIC.


    I have attached a capture of the PIC Program Memory for what its worth.


    I also loaded just the DT_INTS blinky light program onto the PIC without the bootloader. Using the MPLABS debugger i am able to see that when the code gets to the MOVWF PCL, ACCESS instruction it moves 0x34 from WREG into the PCL and the program jumps to 0x0234. The code at 0x0234 looks like the TOGGLELED1: code to actually toggle port b.0.
    The code runs great without the bootloader.

    Comparing the two pieces of code it looks like the bootloader version should be branching to 0x9DC...but instead I think its running off the stack and resetting the PIC.

    I am now going to try and reload the DT_INTS with the bootloader and see if I can capture the PCL, PCLATH and PCLATU registers when the code attempts to move 0xDC into PCL. Hopefully I can see where it is really trying to go.

    Its kind of late here in VA so I may have to tackle this tomorrow night.

    Thanks for all the ideas so far.
    Tom
    Attached Files Attached Files

  8. #8
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Ok, it looks like the code is trying to goto 0xa34 in the attached file.
    It gets to 0x091C - MOVWF PCL, ACCESS and resets the PIC.

    Here are the values for PC:
    Code:
      Update      Address    Symbol Name      Value                      Binary     Char 
    
                     FE8     WREG                   0x34                  00110100    '4'
                     FF9     PCL                    0x1C                  00011100    '.'
                     FF9     PCLAT              0x0A341C 00001010 00110100 00011100  '.4.'
                     FFA     PCLATH                 0x34                  00110100    '4'
                     FFB     PCLATU                 0x0A                  00001010    '.'
    The code should be going to 0x0A34 but instead resets...It never actually moves the 0x34 from Wreg into the PCL.

    Any thoughts?

    Thanks
    Tom
    Attached Files Attached Files

  9. #9
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Thanks for the help Darrel.

    I will look into it further. I had initialized stepcount to 32, then later to 8. Seems to get stuck after about two flashes of the led's.

    Walter

  10. #10
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Maybe you need to set PCLATH before changing PCL?
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Walter,

    Try this. It gives you a lot smaller table by packing two bytes into each word space. If you stick with the RETLW approach just uncomment the addwf WREG.

    Code:
    ASM
    SineTable   
      movlw UPPER Table1
      movwf TBLPTRU
      movlw HIGH Table1
      movwf TBLPTRH
      movlw LOW Table1
      movwf TBLPTRL
      movf _STEPCOUNT,W
      ;addwf WREG     ; uncomment only if using RETLW tables VS db
      addwf TBLPTRL
      TBLRD*
      movf  TABLAT, W
      return
     
    Table1
      db 0,128,148,167,185,200,213,222,228,230,228,222,213,200,185,167
      db 148,128,180,108,89,71,56,43,34,28,26,28,34,43,56,71,89,108
    ENDASM
    Regards,

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

  12. #12
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    I've been trying to use DT_INTS-14 with a 16F877A. I'm getting errors when trying to compile. Code is as follows:
    Code:
    DEFINE    OSC 4
    
    'Define LCD registers and bits
    Define  LCD_DREG        PORTD
    Define  LCD_DBIT        4
    Define  LCD_RSREG       PORTE
    Define  LCD_RSBIT       0
    Define  LCD_EREG        PORTE
    Define  LCD_EBIT        1
    
    'OPTION_REG.6 = 0 
    OPTION_REG.7=0                               'ENABLE PORTB PULLUPS
    ADCON1 = 7                                   
    Low PORTE.2                                  
    Pause 100                                    
    
    'INCLUDE FILES FOR DT INTERRUPTS  
    INCLUDE "DT_INTS-14.bas"
    INCLUDE "ReEnterPBP.bas"
    
    X         VAR  BYTE
    Y         VAR  BYTE
    Z         VAR  BYTE
    COUNTER   VAR  BYTE
    TAG       VAR  BYTE[26]
    
    INIT:
    'INITIALIZE INTERRUPTS
    ASM
    INT_LIST  macro   ;IntSource,Label,Type,ResetFlag?
            INT_Handler  RBC_INT,  _BChange, PBP, yes                  
        endm
        INT_CREATE
    ENDASM
    
    @ INT_ENABLE RBC_INT
    
    START:
    COUNTER=0
    
    MAIN:
    IF COUNTER=>26 THEN
         LCDOUT $FE,1,"COUNTER: ",DEC COUNTER
         LCDOUT $FE,$C0,STR TAG\15
         COUNTER=0
    ENDIF
    GOTO MAIN
    
    BChange:
    COUNTER=COUNTER+1
    IF PORTB.0=0 THEN
         TAG[COUNTER]=0
    ENDIF
    IF PORTB.1=0 THEN
         TAG[COUNTER]=1
    ENDIF
    @ INT_RETURN
    The errors I'm getting are:
    Error [113] c:(path)pbppic14.lib 1181: Symbol not previously defined (wsave)
    Error [101] c:(path)code\lab-x1.asm 194: Error: (wsave variable not found,)
    Error [101] c:(path)code\lab-x1.asm 258: Error: (" Add:" wsave VAR BYTE $70 SYSTEM)
    Error [101] c:(path)code\lab-x1.asm 315: Error: (Chip has RAM in BANK1, but wsave1 was not found.)
    etc
    etc

    Can somebody tell me what's wrong?

    Thanks

  13. #13
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Yes, it is asking you to change the include file here:

    Code:
    wsave   VAR BYTE    $20     SYSTEM      ' location for W if in bank0
    ;wsave   VAR BYTE    $70     SYSTEM      ' alternate save location for W 
                                             ' if using $70, comment out wsave1-3
    
    ' --- IF any of these three lines cause an error ?? ---------------------------- 
    '       Comment them out to fix the problem ----
    ' -- It depends on which Chip you are using, as to which variables are needed --
    wsave1  VAR BYTE    $A0     SYSTEM      ' location for W if in bank1
    wsave2  VAR BYTE    $120    SYSTEM      ' location for W if in bank2
    wsave3  VAR BYTE    $1A0    SYSTEM      ' location for W if in bank3
    It needs to be adjusted for a few different chips. Comment out the wsave at $20, and uncomment the wsave at $70, and try commenting out the wsave1-3.
    Last edited by ScaleRobotics; - 3rd September 2010 at 06:11.
    http://www.scalerobotics.com

  14. #14
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    scalerobotics - Thanks very much.
    Last edited by circuitpro; - 3rd September 2010 at 20:28.

Similar Threads

  1. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  2. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 20:02
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  4. Keypad and DT's Instant Interrupts
    By Homerclese in forum General
    Replies: 11
    Last Post: - 27th April 2007, 06:32
  5. Replies: 1
    Last Post: - 1st November 2006, 03:11

Members who have read this thread : 6

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

Tags for this Thread

Posting Permissions

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