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 CCS Technical Support

PIC16LF1826 setting up PWM [Solved]

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



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

PIC16LF1826 setting up PWM [Solved]
PostPosted: Fri Jul 22, 2022 4:23 am     Reply with quote

Hello,

I am trying to get the PWM working on this device.. but no luck.
Digital I can control the output in..
But PWM is not working...

What am I doing wrong?????

main.c
Code:

#include <main.h>

void main()
{
   setup_adc_ports(sAN0);
   setup_adc(ADC_CLOCK_DIV_32);
   setup_timer_2(T2_DIV_BY_16,255,1);      //819 us overflow, 819 us interrupt

   setup_ccp1(CCP_PWM|CCP_SHUTDOWN_AC_L|CCP_SHUTDOWN_BD_L);
   set_pwm1_duty(512);
   int16 speed = 0;
   delay_ms(500);

   while(TRUE)
   {
      speed=read_adc();
      set_pwm1_duty(speed);
      delay_ms(500);
   }
}


main.h

Code:

#include <16LF1826.h>
#device ADC=16

#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(internal=16MHz)

Jody



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

PostPosted: Fri Jul 22, 2022 5:05 am     Reply with quote

Solved it!!
The PWM output is on RB3 and I was trying to get it working with RB0...

Time for weekend!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19549

View user's profile Send private message

PostPosted: Fri Jul 22, 2022 6:42 am     Reply with quote

You need an extra intravenous coffee!... Very Happy

Have a good weekend.
Jody



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

PostPosted: Fri Jul 22, 2022 7:15 am     Reply with quote

I am going on a holliday...
was a rush job for a costumer......

it is working..
so long and thanks for all the fish!!!
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