Elapsed timer not working as expected at 64MHz


Results 1 to 40 of 56

Threaded View

  1. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,159


    Did you find this post helpful? Yes | No

    Default Re: Elapsed timer not working at 64MHz

    I bet this is my Saleae probe biting me in the nose again; not being able to run it fast enough.

    The interrupt is working faster, I'm probably missing signals.

    Name:  Saleae 64MHz VS 16MHz.PNG
Views: 1351
Size:  34.7 KB

    EDIT: And I notice I didn't align the marker the same way on Probe 1 - Port = 1 / 0, but it's the same interval as described in the WIDTH; 0.250uS, I just rechecked.


    Code:
    asm
    ; __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H & _PLLCFG_OFF_1H & _PRICLKEN_OFF_1H & _FCMEN_ON_1H & _IESO_OFF_1H
     __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H & _PLLCFG_ON_1H & _PRICLKEN_OFF_1H & _FCMEN_ON_1H & _IESO_OFF_1H
     __CONFIG    _CONFIG2L, _PWRTEN_ON_2L & _BOREN_SBORDIS_2L & _BORV_285_2L
     __CONFIG    _CONFIG2H, _WDTEN_OFF_2H
     __CONFIG    _CONFIG3H, _CCP2MX_PORTC1_3H & _PBADEN_OFF_3H & _CCP3MX_PORTE0_3H & _HFOFST_OFF_3H & _T3CMX_PORTB5_3H & _P2BMX_PORTC0_3H & _MCLRE_EXTMCLR_3H
     __CONFIG    _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
    endasm
    
    ;DEFINE OSC 16
    ;OSCTUNE = %10000000
    
    DEFINE OSC 64
    OSCTUNE = %11000000
    
    OSCCON  = %01110000
    OSCCON2 = %00000100
    INCLUDE "DT_INTS-18.bas"
    INCLUDE "ReEnterPBP-18.bas"
    INCLUDE "ReEnterPBP-18LP.bas"
    INCLUDE "Elapsed_INT-18.bas"
    ASM
    INT_LIST  macro    ; IntSource,        Label,           Type,   ResetFlag?
    ;        INT_Handler    RX1_INT,    _RX1Interrupt,    PBP,    yes
        endm
        INT_CREATE                  ; Creates the interrupt processor
    INT_LIST_L  macro  ; IntSource,        Label,           Type,   ResetFlag?
            INT_Handler   TMR1_INT,   _ClockCount,   PBP,  yes
        endm
        INT_CREATE_L                ; Creates the Low Priority interrupt processor
    ENDASM
    ANSELA = %00000000
    ANSELB = %00000000
    ANSELC = %00000000
    ANSELD = %00000000
    ANSELE = %00000000
    ADCON0 = %00000000
    PMD0 = %10111110
    PMD1 = %11011111
    PMD2 = %00001111
    DEFINE USE_LOWPRIORITY 1
    TRISA = %00000000
    TRISB = %00000000
    TRISC = %00000000
    TRISD = %00000000
    TRISE = %00000000
    PORTA = %00000000
    PORTB = %00000000
    PORTC = %00000000
    PORTD = %00000000
    PORTE = %00000000
        pause 100
    @ INT_ENABLE  TMR1_INT                  ; enable Timer 1 interrupts
        GOSUB ResetTime                     ' Reset Time to  0d-00:00:00.00
    MainProgram:
    
        PortD.2 = 1
    
        if T1CON.0 = 0 then
            GOSUB StartTimer                    ' Start the Elapsed Timer
            PortD.3 = 1
        endif
    
        PortD.2 = 0
    
        if ticks = 25 then
            PortD.3 = 0
            GOSUB StopTimer                    ' Stop the Elapsed Timer
            GOSUB ResetTime                     ' Reset Time to  0d-00:00:00.00
        endif
    
        goto MainProgram
    end

    Switch bouncing becomes much more pronounced at 64MHz. I think I'm going to change approach and go the long way and use just a 0.1uF ceramic cap on each pin (I remember that helped somewhat on previous tests).

    Master PIC @ 64MHz
    LED Slave PIC @ 64MHz
    Keypad Slave PIC at 16MHz

    I start DT Timer on a keypress and ignore inputs during that interval. I just have to make tests to see how fast I can press the same button and tweak the delay.

    I wanted to handle both the LEDs and Keypad on the same PIC, but it'll be a lot easier and reliable to just split them up.
    Last edited by Demon; - 22nd December 2014 at 21:05.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. I2CRead & I2CWrite not working as expected
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 30
    Last Post: - 27th October 2021, 18:36
  2. PORTB.3 Input not working as expected.
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th March 2013, 09:58
  3. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  4. SPWM and Elapsed Timer
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 8th May 2008, 03:16
  5. DT Elapsed Timer
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th March 2008, 23:17

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