PBP command execution time


Closed Thread
Results 1 to 17 of 17

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    I can't, I tried 8MHz but the software said it couldn't keep up and lowered the speed.


    EDIT: So I tried another approach and lowered the OSC speed, but I get INVALID OSC DEFINE whenever I try DEFINE OSC 1 or 2.

    PIC 18F44K22, PBP 2.60c, MPASM v5.49

    Code:
    asm
    ; __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H & _PLLCFG_ON_1H & _PRICLKEN_OFF_1H & _FCMEN_ON_1H & _IESO_OFF_1H
     __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H & _PLLCFG_OFF_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 1
    ;DEFINE OSC 64
    
    OSCCON  = %00110000              ' OSCILLATOR CONTROL REGISTER
    ;OSCCON  = %01110000              ' OSCILLATOR CONTROL REGISTER
    ' bit 7 IDLEN: Idle Enable bit
    '     R/W       1 = Device enters Idle mode on SLEEP instruction
    '               0 = Device enters Sleep mode on SLEEP instruction
    ' bit 6-4 IRCF<2:0>: Internal RC Oscillator Frequency Select bits(2)
    '     R/W       111 = HFINTOSC – (16 MHz)
    '               110 = HFINTOSC/2 – (8 MHz)
    '               101 = HFINTOSC/4 – (4 MHz)
    '               100 = HFINTOSC/8 – (2 MHz)
    '               011 = HFINTOSC/16 – (1 MHz)(3)
    '           If INTSRC = 0 and MFIOSEL = 0:
    '               010 = HFINTOSC/32 – (500 kHz)
    '               001 = HFINTOSC/64 – (250 kHz)
    '               000 = LFINTOSC – (31.25 kHz)
    '           If INTSRC = 1 and MFIOSEL = 0:
    '               010 = HFINTOSC/32 – (500 kHz)
    '               001 = HFINTOSC/64 – (250 kHz)
    '               000 = HFINTOSC/512 – (31.25 kHz)
    '           If INTSRC = 0 and MFIOSEL = 1:
    '               010 = MFINTOSC – (500 kHz)
    '               001 = MFINTOSC/2 – (250 kHz)
    '               000 = LFINTOSC – (31.25 kHz)
    '           If INTSRC = 1 and MFIOSEL = 1:
    '               010 = MFINTOSC – (500 kHz)
    '               001 = MFINTOSC/2 – (250 kHz)
    '               000 = MFINTOSC/16 – (31.25 kHz)
    ' bit 3 OSTS: Oscillator Start-up Time-out Status bit
    '       R       1 = Device is running from the clock defined by FOSC<3:0> of the CONFIG1H register
    '               0 = Device is running from the internal oscillator (HFINTOSC, MFINTOSC or LFINTOSC)
    ' bit 2 HFIOFS: HFINTOSC Frequency Stable bit
    '       R       1 = HFINTOSC frequency is stable
    '               0 = HFINTOSC frequency is not stable
    ' bit 1-0 SCS<1:0>: System Clock Select bit
    '       R/W     1x = Internal oscillator block
    '               01 = Secondary (SOSC) oscillator
    '               00 = Primary clock (determined by FOSC<3:0> in CONFIG1H).
    
    OSCCON2 = %00000100              ' OSCILLATOR CONTROL REGISTER 2
    ' bit 7 PLLRDY: PLL Run Status bit
    '     R         1 = System clock comes from 4xPLL
    '               0 = System clock comes from an oscillator, other than 4xPLL
    ' bit 6 SOSCRUN: SOSC Run Status bit
    '     R         1 = System clock comes from secondary SOSC
    '               0 = System clock comes from an oscillator, other than SOSC
    ' bit 5 Unimplemented: Read as ‘0’.
    ' bit 4 MFIOSEL: MFINTOSC Select bit
    '     R/W=0     1 = MFINTOSC is used in place of HFINTOSC frequencies of 500 kHz, 250 kHz and 31.25 kHz
    '               0 = MFINTOSC is not used
    ' bit 3 SOSCGO(1): Secondary Oscillator Start Control bit
    '     R/W=0     1 = Secondary oscillator is enabled.
    '               0 = Secondary oscillator is shut off if no other sources are requesting it.
    ' bit 2 PRISD: Primary Oscillator Drive Circuit Shutdown bit
    '     R/W=1     1 = Oscillator drive circuit on
    '               0 = Oscillator drive circuit off (zero power)
    ' bit 1 MFIOFS: MFINTOSC Frequency Stable bit
    '     R         1 = MFINTOSC is stable
    '               0 = MFINTOSC is not stable
    ' bit 0 LFIOFS: LFINTOSC Frequency Stable bit
    '     R         1 = LFINTOSC is stable
    '               0 = LFINTOSC is not stable
    
    OSCTUNE = %10000000              ' OSCILLATOR TUNING REGISTER
    ;OSCTUNE = %11000000              ' OSCILLATOR TUNING REGISTER
    ' bit 7 INTSRC: Internal Oscillator Low-Frequency Source Select bit
    '     R/W       1 = 31.25 kHz device clock derived from the MFINTOSC or HFINTOSC source
    '               0 = 31.25 kHz device clock derived directly from LFINTOSC internal oscillator
    ' bit 6 PLLEN: Frequency Multiplier 4xPLL for HFINTOSC Enable bit(1)
    '     R/W       1 = PLL enabled
    '               0 = PLL disabled
    ' bit 5-0 TUN<5:0>: Frequency Tuning bits – use to adjust MFINTOSC and HFINTOSC frequencies
    '     R/W       011111 = Maximum frequency
    '               011110 =
    '               • • •
    '               000001 =
    '               000000 = Oscillator module (HFINTOSC and MFINTOSC) are running at the factory calibrated frequency.
    '               111111 =
    '               • • •
    '               100000 = Minimum frequency
    Last edited by Demon; - 16th December 2014 at 18:23.
    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!

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    Robert,
    1, 2 MHz aren't supported oscillator speeds. From the manual:
    There are a limited number of valid numbers that can be used: 3 (3.58MHz), 4, 8, 10, 12, 16, 20, 24, 25, 32, 33, 40, 48, 64. These are the only frequencies for which PBP is able to accurately calibrate its timing.
    As for the Saleae LOGIC....Your computer can't keep up due to loading on the USB bus (or too much other stuff going on). Make sure that the LOGIC it's the only device on that USB Host controller. If you don't know, just try another USB port.

    But, I don't know what was wrong with me this morning. I was probably thinking in terms of instruction cycles of the PIC.....
    If the samplig rate is 4MHz then the shortest resolvable time is of course 250ns and not 1us as I wrote. Even so I'd definitely try to get the sample rate up a notch (or two).

    /Henrik.

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    I was fixated looking at the INCLUDE file, not the manual.

    And I realized after I went to bed that I am offset by one command in my Saleae pic in the other thread. The action occurs AFTER the command, not before, d'uh.

    I remove all other USB peripherals when I do my test and was able to run the pgm at 4MHz and the probe at 8MHz.

    I still get the same structure, but with new timings naturally. It doesn't seem the be missing anything, and it seems neither was the previous attempt.
    Name:  Saleae Charlie-plex 4 pins.PNG
Views: 446
Size:  75.6 KB

    Code:
    mainloop:
        TRISA = %11111100
        PORTA = %00000001       ' LED 1
        PORTA = %00000010       ' LED 2
    
        TRISA = %11110011
        PORTA = %00000100       ' LED 3
        PORTA = %00001000       ' LED 4
        goto mainloop
    End
    Robert
    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!

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    Hi,
    As Richard pointed out earlier, something like TRISA = %11111100 or PortA = %00000001 compiles to TWO assembly instructions:
    movlw low (0FCh)
    movwf TRISA
    each taking one instruction cycle. If the PIC is clocked at 4MHz, one instruction cycle is 1us so TRISA = %11111100 takes two us.

    The Goto MainLoop compiles to a bra instruction which takes two instructions.

    Your complete program executes in 14 cycles, or 14us at 4MHz.

    Then, as have also been pointed out, the compiler MAY inject a clear WDT instruction. Turn it off and tell the compiler to stop tickle the dog if you want to be sure.

    /Henrik.

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: PBP command execution time

    Yup, I got those values also by highlighting from one point in a pass to the same point in the next pass. I couldn't point before the top TRIS, there's no pulse break to select. That's why I used after PORT instead, I can select it at the beginning and end of a pass.
    Name:  Saleae Charlie-plex 4 pins v2.PNG
Views: 417
Size:  76.4 KB
    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. Code speed and execution time
    By aajgss in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 12th May 2011, 03:44
  2. Code execution time?
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th February 2009, 16:07
  3. Execution time in programme
    By Adrian in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th November 2007, 22:29
  4. Command execution time
    By barkerben in forum General
    Replies: 2
    Last Post: - 7th December 2004, 20:29
  5. instruction execution time
    By tjg in forum Code Examples
    Replies: 3
    Last Post: - 21st April 2004, 18:15

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