We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I'm kinda new to this PWM programming (And microboard program). But I've figured out the next code should start a PWM-signal.
// timer 2 initialise T2CON = 0x11; // reload value CRCL = 0x50; CRCH = 0xC9; // compare value CCL1 = 0x18; CCH1 = 0xFC; // P1.1 ??? CCEN = 0x08;
if you look at page 6 of http://www.semiconductors.philips.com/acrobat/datasheets/89C535.pdf you will see that these do not exist in this derivative. Happy new year Erik
Infineon (Siemens) makes an 80C535 which seems to have corresponding registers. Perhaps this is the part in question. Going back to the original post, it looks to me like the code snippet you have initializes Timer 2. But it doesn't do any output of itself. To get a pulse of a particular width out on an external pin, typically you'd do something like set the pin high, start a timer running, and let the timer interrupt handler set the pin low. It looks like this part has a fairly fancy timer 2, so you might be able to use some of those extra compare registers to store two different times, and get interrupts for both high and low transitions of your output. You can set outputs on port 1 simply by writing to the port 1 register, 90H. In Keil headers, it's usually declared:
sfr P1 = 0x90;
sbit Motor0 P1 ^ 0; sbit Motor2 P1 ^ 2;