CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC16F18446 PWM problem [Solved]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
esbelektronik



Joined: 13 Dec 2018
Posts: 23

View user's profile Send private message

PIC16F18446 PWM problem [Solved]
PostPosted: Tue Apr 09, 2019 6:36 am     Reply with quote

Hello,
I use 16F18446 but i can't run pwm1 and pwm2 output. I try close pwm mode and try pin_c2 pin general output pin type output_toggle(pin_c2) command. But it's not change high-low. If i try pin_b6 pin correct.
My code see below.
Code:

#include <16F18446.h>
#fuses NOEXTOSC,RSTOSC_HFINTRC_32MHZ,NOMCLR,NOLVP,NOCLKOUT,BORV27
#device ADC=12
#use delay(internal=32000000)

#pin_select CCP1OUT= PIN_C2
#pin_select CCP2OUT= PIN_C3

#INT_TIMER1
void  TIMER1_isr(void)
{
   set_pwm1_duty(500);
   set_pwm2_duty(255);
   set_timer1(50000);
 


void main()
   {
   SETUP_ADC(ADC_LEGACY_MODE | ADC_CLOCK_DIV_32);
   setup_adc_ports(sAN2 | sAN4 | sAN5);
   setup_oscillator(OSC_HFINTRC_32MHZ | OSC_HFINTRC_ENABLED);
   setup_timer_2(T2_DIV_BY_16,255,1);      //512 us overflow, 512 us interrupt
   setup_ccp1(CCP_PWM);
   setup_ccp2(CCP_PWM);
   setup_timer_1(T1_INTERNAL | T1_DIV_BY_4);
   enable_interrupts(INT_TIMER1);
   enable_interrupts(GLOBAL);

   while(TRUE)
      {
      RESTART_WDT();

     }

   }

_________________
^ ^
(q p) ESB
( V )
L L
esbelektronik



Joined: 13 Dec 2018
Posts: 23

View user's profile Send private message

i solved
PostPosted: Tue Apr 09, 2019 7:43 am     Reply with quote

hello,
I found self mistake. I did change timer2 setup command.
Code:
setup_timer_2(T2_CLK_INTERNAL | T2_DIV_BY_16,255,1);

its work.
_________________
^ ^
(q p) ESB
( V )
L L
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group