Skip to content

Commit

Permalink
Reused Pgm_Pwm_Freq to choose fixed pwm frequency or dynamic pwm
Browse files Browse the repository at this point in the history
  • Loading branch information
damosvil committed Jul 24, 2023
1 parent debeb7b commit 9d82c15
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Bluejay.asm
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ $include (Modules\Macros.asm)
; Programming defaults
;**** **** **** **** **** **** **** **** **** **** **** **** ****
DEFAULT_PGM_RPM_POWER_SLOPE EQU 9 ; 0=Off,1..13 (Power limit factor in relation to rpm)
DEFAULT_PWM_FREQUENCY EQU 24 ; 24=24khz, 48=48khz, otherwise dynamic
DEFAULT_PGM_COMM_TIMING EQU 4 ; 1=Low 2=MediumLow 3=Medium 4=MediumHigh 5=High
DEFAULT_PGM_DEMAG_COMP EQU 2 ; 1=Disabled 2=Low 3=High
DEFAULT_PGM_DIRECTION EQU 1 ; 1=Normal 2=Reversed 3=Bidir 4=Bidir rev
Expand Down Expand Up @@ -299,7 +300,7 @@ _Pgm_Dithering: DS 1 ;
Pgm_Startup_Power_Max: DS 1 ; Maximum power (limit) during startup (and starting initial run phase)
_Pgm_Rampup_Slope: DS 1 ;
Pgm_Rpm_Power_Slope: DS 1 ; Low RPM power protection slope (factor)
_Pgm_Pwm_Freq: DS 1 ;
Pgm_Pwm_Freq: DS 1 ; PWM frequency
Pgm_Direction: DS 1 ; Rotation direction
_Pgm_Input_Pol: DS 1 ; Input PWM polarity
Initialized_L_Dummy: DS 1 ; Place holder
Expand Down Expand Up @@ -360,7 +361,7 @@ _Eep_Pgm_Dithering: DB 000h
Eep_Pgm_Startup_Power_Max: DB DEFAULT_PGM_STARTUP_POWER_MAX
_Eep_Pgm_Rampup_Slope: DB 0FFh
Eep_Pgm_Rpm_Power_Slope: DB DEFAULT_PGM_RPM_POWER_SLOPE ; EEPROM copy of programmed rpm power slope (formerly startup power)
_Eep_Pgm_Pwm_Freq: DB 0FFh
Eep_Pgm_Pwm_Freq: DB DEFAULT_PWM_FREQUENCY ; EEPROM copy of programmed pwm frequency
Eep_Pgm_Direction: DB DEFAULT_PGM_DIRECTION ; EEPROM copy of programmed rotation direction
_Eep__Pgm_Input_Pol: DB 0FFh
Eep_Initialized_L: DB 055h ; EEPROM initialized signature (lo byte)
Expand Down
19 changes: 19 additions & 0 deletions src/Modules/Settings.asm
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,26 @@ ENDIF
mov Pwm_Braking48_L, #0FFh ; Apply full braking if setting is max

decode_throttle_threshold:
; Load chosen frequency
mov Temp1, #Pgm_Pwm_Freq
mov A, @Temp1

; Check 24khz pwm frequency
cjne A, #24, decode_throttle_not_24
mov Throttle_48to24_Threshold, #255
jmp decode_throttle_end

decode_throttle_not_24:
; Check 48khz pwm frequency
cjne A, #48, decode_throttle_not_48
mov Throttle_48to24_Threshold, #0
jmp decode_throttle_end

decode_throttle_not_48:
; Dynamic pwm frequency
; Load programmed throttle threshold into Throttle_48to24_Threshold
mov Temp1, #Pgm_48to24_Threshold
mov Throttle_48to24_Threshold, @Temp1

decode_throttle_end:
ret

0 comments on commit 9d82c15

Please sign in to comment.