using darrel taylor's instant interrupts


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Question

    Hi Darell...Your above code will nevertheless be of value for many...

    I'v finally just about finished writing my first timer template/instant interrupts based program. It just has 1 little bug when compiling...
    If anyone has time, please take a look at this code snippet:

    I am trying to use HPWM on a 16f690 in the main program loop.
    The controlling variable "enabler" is determined by code in the timer1interrupt handler. When it is =1 the hpwm is turned on briefly.

    Turning the HPWM on and off is where I have my problem..
    I get WARNING Bad token " " for the 2 lines that set t2con in the main program loop, but not for the line setting t2con just before the main program loop. Any ideas?

    best regards,
    mike

    ------------------------------------------------------------------------
    DEFINE OSC 4
    OSCCON = %01100110 'should be OK too
    ANSEL = $00
    ANSELH = 0
    ccp1con = 0
    CM1CON0 = 0
    CM2CON0 = 0

    DEFINE I2C_HOLD 1
    DPIN1 var PORTb.4 ' I2C data pin
    CPIN1 var PORTb.6 ' I2C clock pin

    INCLUDE "DT_INTS-14.bas" ; Base Interrupt System
    INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts

    enabler var bit

    ' LOTS MORE VARIABLES DECLARED HERE

    ASM
    INT_LIST macro ' use the format IntSource, Label, Type, ResetFlag?
    INT_Handler TMR1_INT, ReloadTMR1, ASM, no
    INT_Handler TMR1_INT, _MATHhandler, PBP, yes
    endm
    INT_CREATE ; Creates the interrupt processor
    ENDASM

    T1CON = $15 'prescaler; timer on
    @ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts

    T2CON = $00 'HERE I DON'T GET A WARNING

    main:
    IF enabler = 1 THEN 'this variable controlls possible hpwm activation
    TRISC = 1 'Datasheet said to turn off pwm outputs first
    PR2 = 63 'Timer 2 period register
    CCPR1L = 60 'MSBS of DUTYCYCLE
    CCP1CON = %00001100 'CCP1M<3:0> = %1100 P1M<1:0> = %00 'turn on pwm…
    PSTRCON = $0F '%00001111 PULSE STEERING CONTROL REGISTER- send same pwm signal to 4 outputs

    T2CON = %00000100 ' HERE I GET A WARNING -precaler 1:1, postcaler 1:1, bit 2 = Timer2 ON

    TRISC = 0
    enabler = 0
    PAUSE 100 'I could even change the vibration time by software (pause x)
    CCP1CON = 0 'TURN OFF HPWM
    T2CON = %00000000 'HERE I GET A WARNING -TURN OFF TMR2 - minimize power constumption

    TMR2 = 0 'SHOULD RESET THE TIMER
    endif
    goto main


    MATHhandler:

    'ROUTINES THAT DETERMINE WHEN THE VARIABLE ENABLER=1 thus activating a short pwm signal in the main program

    @ INT_RETURN



    ASM
    TimerReload = 30540
    ENDASM
    @Timer1 = TMR1L ; map timer registers to a word variable
    Timer1 VAR WORD EXT
    TimerReload CON EXT ; Get the External Constant
    TMR1ON VAR T1CON.0 ; Alias the Timers ON/OFF bit
    ASM
    ReloadTMR1
    MOVE?CT 0, T1CON, TMR1ON ; 1 stop timer
    MOVLW LOW(TimerReload) ; 1 Add TimerReload to the
    ADDWF TMR1L,F ; 1 value in Timer1
    BTFSC STATUS,C ; 1/2
    INCF TMR1H,F ; 1
    MOVLW HIGH(TimerReload) ; 1
    ADDWF TMR1H,F ; 1
    MOVE?CT 1, T1CON, TMR1ON ; 1 start timer
    INT_RETURN
    ENDASM
    StartTimer:
    Timer1 = TimerReload ; Load Timer
    TMR1ON = 1 ; start timer
    RETURN
    StopTimer:
    TMR1ON = 0 ; stop timer
    RETURN
    --------------------------------------------------------------------------

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Punctuation

    Hello Michael,
    I "ASS-U-ME" you copied and pasted this code from your microcode studio or other editor. If so, then you have a punctuation error:
    INT_LIST macro <font color=red>'</font color> use the format IntSource, Label, Type, ResetFlag? <p> In assembly comments always use ; not ' <p> That fixes the error, still get lots of warnings though, still working on it.
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thank you for the heads up Joe!
    When I compile I only those 2 warnings though... Please post what other warnings you get when compiling...

  4. #4


    Did you find this post helpful? Yes | No

    Angry

    Now that I am declaring T2CON IN HEX that part is working, and I am not getting any more bad token errors. I see what you meant about the many warnings... Looks like I will have to spend more time debugging...

    Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F690 "PWMPROG.ASM" /l"PWMPROG.lst" /e"PWMPROG.err"
    Warning[205] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 769 : Found directive in column 1. (endm)
    Warning[206] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 770 : Found call to macro in column 1. (INT_CREATE)
    Warning[206] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 767 : Found call to macro in column 1. (INT_Handler)
    Warning[206] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 768 : Found call to macro in column 1. (INT_Handler)
    Warning[206] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 966 : Found call to macro in column 1. (MOVE?CT)
    Warning[203] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 967 : Found opcode in column 1. (MOVLW)
    Warning[203] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 968 : Found opcode in column 1. (ADDWF)
    Warning[203] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 969 : Found opcode in column 1. (BTFSC)
    Warning[203] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 970 : Found opcode in column 1. (INCF)
    Warning[203] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 971 : Found opcode in column 1. (MOVLW)
    Warning[203] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 972 : Found opcode in column 1. (ADDWF)
    Warning[206] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 973 : Found call to macro in column 1. (MOVE?CT)
    Warning[206] C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\PWMPROG.ASM 974 : Found call to macro in column 1. (INT_RETURN)
    Loaded C:\Documents and Settings\Admin\Desktop\PWMPROG.cod.
    BUILD SUCCEEDED: Mon Jul 30 13:24:24 2007

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


    Did you find this post helpful? Yes | No

    Default

    Be carefull with the spacing of ASM statements.

    In particular ... (quoted from Post #6)
    Code:
    ASM
    INT_LIST macro ' use the format IntSource, Label, Type, ResetFlag? 
    INT_Handler TMR1_INT, ReloadTMR1, ASM, no
    INT_Handler TMR1_INT, _MATHhandler, PBP, yes
    endm
    INT_CREATE ; Creates the interrupt processor
    ENDASM
    Should be ...
    Code:
    ASM
    INT_LIST macro ; use the format IntSource, Label, Type, ResetFlag? 
        INT_Handler TMR1_INT, ReloadTMR1, ASM, no
        INT_Handler TMR1_INT, _MATHhandler, PBP, yes
        endm
        INT_CREATE ; Creates the interrupt processor
    ENDASM
    DT

  6. #6


    Did you find this post helpful? Yes | No

    Talking

    THANK YOU DT! I just came home from a strenuous day at the hospital...and that piece of information was very uplifting...I thought I would be banging my head for at least a month trying to solve those...

    IN CASE ANY OTHER NEWBIES ARE READING, HERE IS THE LAST PIECE OF CODE THAT HAD WRONG INDENTATION/SPACING AND HAS BEEN CORRECTED:

    ASM
    ReloadTMR1
    MOVE?CT 0, T1CON, TMR1ON ; 1 stop timer
    MOVLW LOW(TimerReload) ; 1 Add TimerReload to the
    ADDWF TMR1L,F ; 1 value in Timer1
    BTFSC STATUS,C ; 1/2
    INCF TMR1H,F ; 1
    MOVLW HIGH(TimerReload) ; 1
    ADDWF TMR1H,F ; 1
    MOVE?CT 1, T1CON, TMR1ON ; 1 start timer
    INT_RETURN
    ENDASM


    My code now compiles fine and i will have the chance to test it on the weekend. Apparrently i will have to buy a decent book on assembly after my next exam in october. Also I will clearly have to find a way to send beer to Darrell

  7. #7


    Did you find this post helpful? Yes | No

    Default

    UNFORTUNATELY IT IS NOT BEING DISPLAYED CORRECTLY HERE... JUST HAVE A QUICK LOOK at http://darreltaylor.com/DT_INTS-14/TimerTemplate.html

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. darrel taylor's instant interrupt compiler error
    By delta_boogie in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 20th October 2009, 19:07
  3. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  4. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 20:02
  5. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48

Members who have read this thread : 2

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