PBPL (Long version) + HPWM?


+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118

    Default PBPL (Long version) + HPWM?

    Hi,

    Could someone please clarify?

    In the PBP manual at section 3.1- Usage it indicates:
    "PBPL can only be used with the PIC18 devices"

    In section 5.33 - PWM it indicates:
    "For the non-long versions of PBP (PBP and PBPW), the highest frequency at any oscillator speed is 32767Hz.

    I am using a 16F628A
    Sending to the PIC this command:
    Code:
    HPWM 1,127,40000
    Looking at the scope I observe 40.1KHz (close enough)

    So does this mean there is a mistake in the manual? or does it mean I will burn my PIC shortly if I continue running at this frequency?

    Thanks

    Mike

  2. #2
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118

    Default

    I guess that's a hard one to answer!
    I see that PBP lets me go up to 65,535 however having a value of greater than 62000 the frequency goes down. Which I can understand with a 4MHz OSC.

    I had the circuit running since yesterday with:
    Code:
    HPWM 1,127,60000
    Which gives 62.7KHz and it is still going so I will stick with the possibility that there is a mistake in the PBP manual unless someone comes up with a better explanation.
    I am using 2.60 and manual is dated 6/09.

    Mike

  3. #3
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118

    Default

    I am sorry to bring this up again but no replies from anyone is affecting my sleep.
    I just need to be reassured with a confirmation that HPWM does go way past the 32767 Hz with a 16F628A contrary to what is indicated in the latest PBP book. V2.60

    Because I keep reading threads about this limit that are suggesting that a miracle is happening on my bench.

    I have reduced my code to this and I am reading 40.1 KHz on the scope.
    Code:
    @ __config _XT_OSC & _WDT_OFF & _MCLRE_ON & _LVP_OFF & _CP_OFF
    
    DEFINE OSC 4
    TRISA = $07               
    TRISB = $05  
    CMCON = $06
    INTCON = $10
    OPTION_REG = $C0
    
    HPWM 1,127,40000
    
    MAIN:
        pause 1
    GOTO MAIN
    
     end

  4. #4
    Join Date
    May 2007
    Posts
    604

    Default

    Depending on the resolution required and by setting the CCP registers manually, the hardware is capable of running up into the MHz region.

  5. #5
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118

    Default

    I have updated my code to this:
    Code:
    @ __config _XT_OSC & _WDT_OFF & _MCLRE_ON & _LVP_OFF & _CP_OFF
    
    CLEAR
    DEFINE OSC 4
    TRISB = $05  
    CMCON = $07
    
    HPWM 1,127,40000
    
    MAIN:
        pause 1
    GOTO MAIN
    
     end
    I still get 40.1KHz and I have not affected CCP registers manually

  6. #6
    Join Date
    May 2007
    Posts
    604

    Default

    When working with hardware peripherals (such as CCP/PWM, USART, etc.) I will set up the registers manually - that way I know exactly what the peripheral is doing. You will also save a significant amount of code space by not having the compiler/device perform what can sometimes be pretty math intensive operations.

Posting Permissions

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