Updating HPWM frequently, safe?


Closed Thread
Results 1 to 40 of 79

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by Darrel Taylor View Post
    There had to be more errors than that.
    The others might have had more clues, but it appears that PBP couldn't find the file.

    Are you saying that you renamed it to HPWM.bas but still had INCLUDE "HPWM10.pbp"?

    confused.
    <br>
    Hi, Darrel,

    Hoooo ... bad evening ! was HPWM10.pbp into HPWM10.bas.

    the goal was to transform a R/C pulse into a corresponding 10 bits PWM @ 10 kHz ... and drive a "Diesel engine" sound machine.

    Have a nice week end.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Red face

    Hi, Darrel

    I Was a bit surprised by those lines :

    Code:
     Line    Address    Opcode        Label                    Disassembly              
    
        359     166       00BD                    MOVWF 0x3d                             
        360     167       084C                    MOVF _HP_Channel, W                    
        361     168       3C05                    SUBLW 0x5                              
        362     169       1C03                    BTFSS STATUS, 0                        
        363     16A       2975                    GOTO L00001                            
        364     16B       3001                    MOVLW 0x1                              
        365     16C       008A                    MOVWF PCLATH                           
        366     16D       084C                    MOVF _HP_Channel, W                    
        367     16E       0782                    ADDWF PCL, F                           
        368     16F       297A                    GOTO _GetCH_2                          
        369     170       2975                    GOTO L00001                             
        370     171       297A                    GOTO _GetCH_2                          
        371     172       297A                    GOTO _GetCH_2                          
        372     173       297A                    GOTO _GetCH_2                          
        373     174       297A                    GOTO _GetCH_2                          
        374     175       0813   L00001           MOVF CCPR1L, W                         
        375     176       00C0                    MOVWF _HP_Temp                         
        376     177       0815                    MOVF CCP1CON, W                        
        377     178       00C1                    MOVWF _HP_Temp??HIGHBYTE               
        378     179       297A                    GOTO _GetCH_2                          
        379     17A       0840   _GetCH_2         MOVF _HP_Temp, W                       
        380     17B       00A0                    MOVWF BANK0_START                      
        381     17C       01A1                    CLRF 0x21                              
        382     17D       3002                    MOVLW 0x2                              
        383     17E       205A                    CALL SHIFTL
    are those 6 times " GOTO _GetCH_2 " ( L368 , 370 - 373 , 378 ) something " regular " ???


    the source for 12F683 @ 8 Mhz internal is :

    Code:
    @ __config _INTRC_OSC_NOCLKOUT &_FCMEN_OFF &_IESO_OFF & _WDT_ON &_PWRTE_ON & _MCLRE_OFF & _CP_OFF
    
     OSCCON = %01110111					' Internal Clock 8 Mhz
     
     CMCON0 = 7
     VRCON  = 0
     ADCON0 = 0
     ANSEL  = 0
    
     DEFINE OSC 8                   	'Declare 8 Mhz operation 
     DEFINE PULSIN_MAX 4500
    
     
    ' PINS DEFINITIONS
    
    	Signal	var GPIO.3
    	Drive	var GPIO.2
    	
    	GPIO	= 0	
    	TRISIO 	= %00001000
    
    	
    ' VARIABLE DEFINITIONS
    
      	speed     	var Word              	' assign Word variable to speed demand
      	w1			var Word				' Table	output
      	
      	DutyCycle  	VAR WORD
    	Frequency 	VAR WORD
    	Temp       	VAR WORD	
    		
    
    	include "HPWM10.bas"
    
    	LOW Drive  ; Set CCP1 pin to output low
    
    	Frequency = 10000
    
    '******************************************************************************
    'MAIN LOOP
     main:
      
    
       pulsin Signal,0,speed				' Read servo pulse ( Inverted !!! ) 
               
    '******************************************************************************
    ' Throttle amount topped to 100 and reduced to 25 steps
      
       if speed > 300 then
         speed = ( speed - 300 )MIN 100
       else
         speed = ( 300 - speed )MIN 100
       endif
        
       speed = speed >> 2
       
    '******************************************************************************
    ' Conversion logarithmique 10 bits - 800 maxi à 10 khz
    
    	
    	lookup2 speed, [0,0,161,277,378,467,543,611,670,721,766,804,836,867,893,_
    	 933,950,965,978,990,1000,1009,1017,1023,1023 ],w1                     	                     
    
    '******************************************************************************           
    ' !!! Passer en " HPWM 10 " !!!
    
        if w1 <> DutyCycle then  DutyCycle = w1
        
        @ HPWM10 1, _DutyCycle, _Frequency  
         
       goto main
    
    END
    Regards

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Darrel

    I Was a bit surprised by those lines :
    ...
    are those 6 times " GOTO _GetCH_2 " ( L368 , 370 - 373 , 378 ) something " regular " ???
    The lines showing the same labels is the result of Disassembling.
    There are actually 6 different labels, with the code in-between optimized out since the chip doesn't have 5 CCP modules.

    It comes from this section ...
    Code:
    ;-----  Get Current DutyCycle ------------------------------------------------
        Branch HP_Channel,[GetCH_Done,GetCH_1,GetCH_2,GetCH_3,GetCH_4,GetCH_5]
    
        GetCH_1:
                ASM
                  ifdef CCP1CON  
                    MOVE?BB  CCPR1L,  _HP_Temp
                    MOVE?BB  CCP1CON, _HP_Temp + 1
                    goto _GetCH_Done        
                  endif  
                endasm
        GetCH_2:  
                ASM
                  ifdef CCP2CON  
                    MOVE?BB  CCPR2L,  _HP_Temp
                    MOVE?BB  CCP2CON, _HP_Temp + 1
                    goto _GetCH_Done        
                  endif  
                endasm
    The GOTO's are created by the Branch statement.
    And it looks like this in the .LST file ...
    Code:
    016B   3001               M         movlw   (jmptbl) >> 8
    016C   008A               M         movwf   PCLATH
    016D   084C               M         movf    _HP_Channel, W
    016E   0782               M         addwf   PCL, F
    016F                      M jmptbl
    016F   297A               M         goto    _GetCH_Done
    0170   2975               M         goto    _GetCH_1
    0171   297A               M         goto    _GetCH_2
    0172   297A               M         goto    _GetCH_3
    0173   297A               M         goto    _GetCH_4
    0174   297A               M         goto    _GetCH_5
    0175                      M L00001
    0175                      M _GetCH_1
    0175   0813               M         movf    CCPR1L, W
    0176   00C0               M         movwf   _HP_Temp
    0177   0815               M         movf    CCP1CON, W
    0178   00C1               M         movwf   _HP_Temp + 1
    0179   297A           00326                 goto _GetCH_Done        
    017A                      M _GetCH_2
    017A                      M _GetCH_3
    017A                      M _GetCH_4
    017A                      M _GetCH_5
    017A                      M _GetCH_Done
    Since the labels are all at the same address, the disassembler chooses the first label it finds at that address (_GetCH_2).
    DT

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Smile

    Hi, Darrel

    Tanks for your explanation

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. need help on hpwm
    By helmut in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th August 2007, 15:49
  2. HPWM of the port of two HPWM
    By ja2rqk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th April 2007, 15:05
  3. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 14:14
  4. HPWM and A to D interaction question 18F252
    By tcbcats in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 10th May 2006, 03:50
  5. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43

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