PDA

View Full Version : Multiple HPWM question



Johan
- 16th October 2007, 16:50
Hello,

I just made an experiment with 18F4431 again.
The blinky program works, and now I want to have multiple / simultanous HPWM
My code did not work, How to setup so the RB0,1,2,3 become PWM PORT ? Is there any other register to modify ? Thanks



DEFINE OSC 8 ' Oscilator HS

TRISA = %00000000 ' Set PORTA to all output
TRISB = %00000000 ' Set PORTB to all output
TRISC = %00000000 ' Set PORTC to all input
TRISD = %00000000 ' Set PORTD to all output
TRISE = %00000000 ' Set PORTE to all output
ANSEL0= %00000000 ' Analog channel AN0-AN7 off
ANSEL1= %00000000 ' Analog channel AN8 off

main:
hpwm 0, 100, 7000 'RB0 as hpwm output
hpwm 1, 180, 7000 'RB1 as hpwm output
hpwm 2, 250, 7000 'RB2 as hpwm output
goto main

Bruce
- 16th October 2007, 19:54
See the example in this thread http://www.picbasic.co.uk/forum/showthread.php?t=7095

Between that & the data sheet you should be able to get it going.

Johan
- 17th October 2007, 13:00
Thank you Bruce,

It works :)