This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[PWM] what ports to use?

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;
Now, does this code send output to Port 1, Pin 1? Or do we software engineers call that pin 0?

And if so, how can I send output to pin 3? Or start a second PWM signal?

What I need to do:
Send 2 different PWM signals to 2 motors. Am I doing something good here? (Motors are attached to pin0, and pin2)

Plz help this newbie... :)

ps. I did search the forums, and more, couldn't find an easy-to-use example ...

Parents
  • Good question ;)

    From my documentation:
    TCON, Timer Control Register
    CCEN, Compare/capture enable register
    CCL1, Compare/capture register 1, low byte
    CCH1, Compare/capture register 1, high byte
    T2CON, Timer 2 control register
    CRCL, Compare/reload/capture register, low byte
    CRCH, Compare/reload/capture register, high byte.

    And To try and draw it.

    T2 |--/-------\----|
    ^ ^0xFFFF
    | /--> CCL
    \--> CRC

    T2 = Timer, counts from 0x0000 to 0xFFFF
    CRC = Start, after 0xFFFF has been reached, start counting from here
    CCL = Compare, after this point, set pin x high (What is x? is that port 1 pin 1?)

Reply
  • Good question ;)

    From my documentation:
    TCON, Timer Control Register
    CCEN, Compare/capture enable register
    CCL1, Compare/capture register 1, low byte
    CCH1, Compare/capture register 1, high byte
    T2CON, Timer 2 control register
    CRCL, Compare/reload/capture register, low byte
    CRCH, Compare/reload/capture register, high byte.

    And To try and draw it.

    T2 |--/-------\----|
    ^ ^0xFFFF
    | /--> CCL
    \--> CRC

    T2 = Timer, counts from 0x0000 to 0xFFFF
    CRC = Start, after 0xFFFF has been reached, start counting from here
    CCL = Compare, after this point, set pin x high (What is x? is that port 1 pin 1?)

Children