"Single-Chip" "710" PWM

Source: Internet
Author: User

710 PWM has two ways to output, generally by the output comparison to do PWM. It can choose Timer2 or Timer3 as its time base. The state of the output pin changes when the timer value matches the comparison register value

The output comparison module has 7 modes of operation

Low/High Active single event mode

    • Flip Mode
    • Delay Single Event mode
    • Continuous Single Event mode
    • PWM mode without fail-safe
    • PWM mode with fail-safe

Ocm<2:0> to choose the comparison mode, how to choose to see the chip data bar, 178 pages

The detailed initialization code for the PWM is as follows (OC1 is selected, a total of 9. OC1-OC8)

1     //Initialize Output Compare Module2OC1CONBITS.OCM = 0b000;//Disable Output Compare Module3OC1R = -;//Write the duty cycle for the first PWM pulse4Oc1rs = $;//Write the duty cycle for the second PWM Pulse5Oc1conbits.octsel =0;//Select Timer2 As output compare time base6OC1R = -;//load the Compare Register value (load compare memory values)7OC1CONBITS.OCM = 0b110;//Select the PWM mode8     9     Ten     //Initialize and enable Timer2 OneT2conbits.ton =0;//Disable Timer AT2conbits.tcs =0;//Select internal instruction cycle clock (select internal instruction cycle clocks)) -T2conbits.tgate =0;//Disable Gated Timer mode -T2CONBITS.TCKPS = 0b00;//Select 1:1 prescaler the      -TMR2 =0x00;//Clear Timer Register -PR2 = -;//load the period value (load cycle value) -      +Ipc1bits.t2ip =0x01;//Set Timer2 Interrupt Priority level -Ifs0bits.t2if =0;//Clear Timer2 Interrupt Flag +Iec0bits.t2ie =1;//Enable Timer2 Interrupt A      atT2conbits.ton =1;//Start Timer

Only the first half of the PWM can be initialized. The back allows Timer2 to be put in other places.

"Single-Chip" "710" PWM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.