Chaps,
hope this is the correct place. Can't seem to get PWM working, this is my PWM
set up routine is below. Have not tried it in hardware - but gpsim shows the
correct pin set to an output but it does not have a signal on it.
Thoughts?
Pete
void pwm_setup() {
//Set PR2 to 255 - set PWM period
PR2 = 0xFE;
//Set up timer 2 prescaler which is also used by the PCM module
// 00 = 1:1 prescaler
// 01 = 1:4 prescaler
// 1x = 1:16 prescaler
T2CKPS0 = 0;
T2CKPS1 = 0;
//With the above settings and 4MHz crystal we are looking at about 3.9
kHz
PWM
//period.
//LSB for the PWM period counter, bits 5 and 4 - set to zero
//CCP1CON = CCP1CON & 207;
//CCP1CON = CCP1CON | 1 | 2| 4| 8; //set them high!
CCP1CON = 15;
//MSB - set at something mid way for testing. Will be zero for final
set up;
CCPR1L = 0x80;
//Timer 2 on
TMR2ON = 1;
//Set up TRISB bit 3 as output - clear this bit
TRISB = TRISB & 247;
}
Can post full code and make file if it helps.
Pete
--
Peter Chant
http://www.petezilla.co.uk
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user