Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] MicroC Pro PWM not working with 16F73 need help

Status
Not open for further replies.
Newbie level 1
Joined
Sep 27, 2023
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
20
MicroC Pro PWM not working with 16F73 need help

unsigned short duty_c; // Define variable duty_c

void initMain() {
ANSEL = 0;
PORTC = TRISC = 0;
PWM1_Init(50);
}

void main() {
initMain();
duty_c = 127; // Initial value of duty-cycle
PWM1_Start(); // Start PWM1 module
PWM1_Set_Duty(duty_c); // Set PWM duty-cycle to 50%
}
 

"Not working" is a very bad error description - it really tells us nothing.
However one thing that stands out is that your main function has no main loop - something that is essential for any embedded system: it has to keep running 'forever'.
In your case, you seem to set everything up (although it is impossible to tell with out the full code, including the config options) so adding a simple "while(1);' as the last statement is probably what you need.
I' not certain about the 'mikroC' runtime, but may C runtimes will take the exit from the 'main' function as an indication of something going very wrong and will then reset and reinitialise the whole MCU before starting again. If that is the case then you re simply in a continuous loop of resetting the MCU, running your code before resetting again. Therefore the PWM never gets a chance to do anything.
Susan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top