PDA

View Full Version : HPWM of the port of two HPWM



ja2rqk
- 24th April 2007, 13:21
questions on two ports was used.
There is production winkers.
The operation of HPWM doesn't move normally.
The operation only of one port is something strange though it seems
to move.
The second port doesn't operate.
The operation of usual HI and LOW is normal.
I do not understand the cause though it is thought that the part
related to HPWM is bad because the blinking mode becomes a defective
operation, too, when changing it from the PWM mode into the blinking mode.
It buys and it experiments on PIC16F616 that HPWM is a lot of.
Please teach if there is what becomes some references.

code:
'Control of Winkers

PORTC=0
TRISC=0
ADCON0 = 0
ANSEL = 0

DEFINE HPWM2_TMR 2

Duty var byte
T VAR WORD
INPA var byte

IL var PORTA.1
IR var PORTA.2
SELSW var PORTA.4

LEDL VAR PORTC.5
LEDR VAR PORTC.4

t=1000

Start:
TRISA = %11111111
INPA = PORTA
IF INPA=%00000010 then gosub LPWM
IF INPA=%00000100 THEN GOSUB RPWM
IF INPA=%00010010 then gosub LPulse
IF INPA=%00010100 THEN GOSUB RPulse
' bit5 modeSW
goto Start


LPWM: 'Lch PWMOUT
for duty =0 to 255 step 2
hpwm 2,DUTY,1000
next
for duty =255 to 0 step -2
hpwm 2,DUTY,1000
next
return

RPWM: 'Rch PWMOUT
For duty =0 to 255 step 2
hpwm 1,DUTY,2000
next
for duty =255 to 0 step -2
hpwm 1,DUTY,2000
next
return

'Lch out HiLow
LPulse:
HIGH LEDL
PAUSE T
LOW LEDL
PAUSE T
return

'Rch out HiLow
RPulse:
HIGH LEDR
PAUSE T
LOW LEDR
PAUSE T
return

end

skimask
- 24th April 2007, 14:22
DEFINE HPWM2_TMR 2


Should be:
DEFINE HPWM2_TIMER 2

You might not get a compiler error, but the compiler will take any DEFINE...such as

DEFINE THIS_IS_A_LOAD_OF_CRAP 1

and ignore it if it doesn't apply to anything.

ja2rqk
- 25th April 2007, 06:42
Thank you for answering.
It did not change though the register value related to the setting related to DEFINE or HPWM was reviewed.
HPWM is difficult though it experimented variously.
The method of the output to two ports has not been understood simultaneously with one from using the HPWM command in two ports though it came to operate by a usual PWM instruction.
There is the site that becomes some references or it looks for.
Even if the manual is seen, it is difficult.
It operates by the following PWM instruction.
It is the one to blink the output by PWM or the pulse picking up the winker signal.
It looks for the reference because two channel output simultaneously has the necessity for using HPWM.

'Control of Winkers PWM

PORTC=0
TRISC=0
ADCON0 = 0
ANSEL = 0

Duty var byte
T VAR WORD
INPA var byte

IL var PORTA.1
IR var PORTA.2
SELSW var PORTA.4

LEDL VAR PORTC.5
LEDR VAR PORTC.4

steps VAR WORD
cycles var Word
t=1000
cycles=1

Start:
TRISA = %11111111
INPA = PORTA
IF INPA=%00000010 then gosub LPWM
IF INPA=%00000100 THEN GOSUB RPWM
IF INPA=%00010010 then gosub LPulse
IF INPA=%00010100 THEN GOSUB RPulse
' bit5 modeSW
goto Start


'Lch out PWM
LPWM:
upL:
For steps=0 TO 255 step 5
PWM LEDL,steps,cycles
Next
High LEDL
Pause 100
downL:
For steps=255 TO 1 STEP -5
PWM LEDL,steps,cycles
Next
Low LEDL
Pause 100
INPA=0
return

'Rch out PWM
RPWM:
upR:
For steps=0 TO 255 step 5
PWM LEDR,steps,cycles
Next
High LEDR
Pause 100
downR:
For steps=255 TO 1 STEP -5
PWM LEDR,steps,cycles
Next
Low LEDR
INPA=0:Pause 100
return

'Lch out HiLow
LPulse:
HIGH LEDL
PAUSE T
LOW LEDL
PAUSE T
return

'Rch out HiLow
RPulse:
HIGH LEDR
PAUSE T
LOW LEDR
PAUSE T
return

end

skimask
- 25th April 2007, 15:05
ADCON0 = 0
ANSEL = 0


Check your 16F616 datasheet concerning these 2 registers and the pins that you are trying to use.