I tried below code. the push button code works fine, the ADC also works fine, but the PWM not working at all.
can someone share knowledge what went wrong with the code.
Code: Select all
#include <built_in.h>
bit oldstate;
void main() {
OSCCON =0xFB;
TRISA = 0x0E; // set direction to be output
ANSELA=0x04;
TRISC = 0xF0; // set direction to be output
PWM1_Remappable_Init(1000);
PWM1_Remappable_Set_Duty(200); PWM1_Remappable_Start();
ADC_Init();
LATC = 0x00;
do { //if (Button(&PORTA, 1, 1, 1)) { // Detect logical one
//oldstate = 1; // Update flag
if (ADC_Read(2) >512){
LATA = 0x00; // Turn OFF LEDs on PORTA
// // Turn OFF LEDs on PORTC
Delay_ms(1000); // 1 second delay
LATA = 0x1; // Turn ON LEDs on PORTA
//LATC = 0xFF; // Turn ON LEDs on PORTC
Delay_ms(1000); // 1 second delay
} } while(1); // Endless loop}
}