PIC18, MPLAB X IDE, XC8, PWM, buzzer
4MHz clock을 통해 Timer2에 4KHz pwm 을 테스트하였습니다.
0. 참고 사항
- [ ] https://openlabpro.com/guide/pulse-width-modulation-using-pic18f4550/
- [ ] http://www.micro-examples.com/public/microex-navig/doc/097-pwm-calculator.html
- [ ] https://www.microchip.com/wwwproducts/en/PIC18F4520
- [ datasheet ] http://ww1.microchip.com/downloads/en/devicedoc/39631a.pdf
1. HW 연결
2. 소스 설명
full 소스는 아래 github를 통해 확인하세요.
Period = 4 * TOSC * (PR2 + 1) * (TMR2 Prescale Value) void pwm_Init(unsigned char period){ // CCP1CON REGISTER (ECCP1 MODULE, 40/44-PIN DEVICES) // T2CON: TIMER2 CONTROL REGISTER void main(void) pwm_Init(249); ... } |
3. 소스
4. 결과
'PIC18' 카테고리의 다른 글
PIC18, MPLAB X IDE, XC8, SPI, at45dbxx data flash (0) | 2018.09.13 |
---|---|
PIC18, MPLAB X IDE, XC8, I2C, pcf8563 (0) | 2018.09.13 |
PIC18, MPLAB X IDE, XC8, UART, rx_interrupt (0) | 2018.09.12 |
PIC18, MPLAB X IDE, XC8, UART, printf (2) | 2018.09.12 |
PIC18, MPLAB X IDE, XC8, TIMER, Interrupt (0) | 2018.09.12 |