View previous topic :: View next topic |
Author |
Message |
Jody
Joined: 08 Sep 2006 Posts: 182
|
PIC16LF1826 setting up PWM [Solved] |
Posted: Fri Jul 22, 2022 4:23 am |
|
|
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
|
|
Posted: Fri Jul 22, 2022 5:05 am |
|
|
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: 19734
|
|
Posted: Fri Jul 22, 2022 6:42 am |
|
|
You need an extra intravenous coffee!...
Have a good weekend. |
|
 |
Jody
Joined: 08 Sep 2006 Posts: 182
|
|
Posted: Fri Jul 22, 2022 7:15 am |
|
|
I am going on a holliday...
was a rush job for a costumer......
it is working..
so long and thanks for all the fish!!! |
|
 |
|