From the manual
Originally Posted by PBP Manual
From the manual
Originally Posted by PBP Manual
Wisdom is knowing what path to take next... Integrity is taking it.
Ryan Miller
Manual? What's that?
That being said...
PIC16F877A datasheet, DS39582B, Table 8-3, Page 68, says you can do 156.3Khz with a 7 bit resolution...if capable of manually setting the registers 'by hand'...
And I'm not 100% sure, but I think with PBPL, you can actually set those frequencies to a much higher value, as long as you're using PBPL and an 18F series PIC. I know I've got a LONG variable driving my HPWM on my 18F4685...can't remember if it goes over 32767 though...
Last edited by skimask; - 10th September 2008 at 17:55.
So in other words, you won't be able to use the HPWM command for that high of a frequency. But as Skimask points out, you can achieve that frequency by setting up the PWM registers manually. As mentioned, section 8.3 of the PIC16F87XA datasheet will explain this. If you get stuck, ask.... I've never set these up before, but I'm pretty confident someone here can guide you.
Wisdom is knowing what path to take next... Integrity is taking it.
Ryan Miller
With an 8MHz clock on a PIC16, the closest you can get is 125kHz (PR2=7) or 111kHz (PR2=8). Also, the resolution will be less than 4 bits (0-8 or just a little more than 3 bit resolution).
i've come out with manually pwm generator coding.this is my code:
DEFINE OSC 8
TRISC.2=0
PWM_STATUS VAR PORTC.2
MAIN:
HIGH PWM_STATUS
PAUSEUS 4
LOW PWM_STATUS
PAUSEUS 4
GOTO MAIN
END
total time per cycle=4u+4u=8us...so...f=125khz...i hope this will work.i will tested it today...
Except that it'll take at least one cycle to set the pin high (probably 2), one cycle to set the pin low (probably 2), 2 cycles to execute the GOTO MAIN...
And if you'd read your PBP manual, you'd notice that pauseus has a minimum delay of 12us vs. the 4us you want.
Therefore, you're code will probably output a 50% duty cycle square wave at about 66.6Khz...give or take...
And do you want actual PWM or just a 120Khz pulse? 2 totally different things you know...
Last edited by skimask; - 11th September 2008 at 00:33.
just 120khz pulse only one time use.actually,i want to inject the pulse when the zero-crossing interrupt occur to couple with the 50hz ac power line.the zero-crossing interrupt has be discuss before in this forum.
Bookmarks