Hello guys!
I want to make a PWM for PIC 16F84A and a DC motor. I use Mplab ide and hitech C compiler.
I have found some code on the internet but I have got an error when I compile it:
Error [192] D:\Documents\cod licenta\licenta (1).c; 17.1 undefined identifier "OPTION_REG"
Can you give me some advice to get rid of this error, or maybe another source code for a PWM?
In the attachment you will find the code if you want to look on it.
Thank you!
Have a nice evening
Thank you very much!
Now it is working but it is not functional in Proteus.
Do you have an example of a pwm generator code? Or some suggestions of how to modify the existing code.
Thanks
I believe the reaction was for the old device. Nothing wrong with old devices, but it just makes your life more difficult. The '84A is well over 20 years old, expensive, doesn't have many peripherals, and poor support. Almost all of the existing projects for it will happily work on other PIC16's.
Precisely. Make your life easier!
Anyway, The code you have posted is 100% okay, as to make a software pwm you have to do three things
1)set up a timebase, try also to use an interrupt so jitter will be reduced
2)set up three registers: counter, period,duty.
3)inside the interrupt (or at each timebase event) do the following:
- increase counter
- if counter is greater or equal than period reset counter
- if counter is less or equal than duty out is low/high, otherwise out is high/low