View previous topic :: View next topic |
Author |
Message |
charlieAguda
Joined: 18 Mar 2019 Posts: 1
|
Option invalid Software PWM Currently not Supported |
Posted: Mon Mar 18, 2019 1:25 pm |
|
|
I'm trying to compile this code, however i encounter some errors that says Option invalid Software PWM Currently not Supported. How can i fix this ? I'm using CCS C Compiler v5.015 in MPLAB X.
Code: |
// DC motor control using PIC16F84A and L293D CCS C code
// http://ccspicc.blogspot.com/
// [email protected]
#include <16F84A.h>
#fuses HS,NOWDT,PUT,NOPROTECT
#use delay(clock = 8000000)
#use fast_io(A)
#use fast_io(B)
#use pwm(output = pin_a0, output = pin_a1, timer = 0, frequency= 500Hz, duty = 0, FORCE_HW)
unsigned int8 i = 1;
void main() {
port_b_pullups(TRUE); // Enable PORTB pull-ups
output_a(0); // PORTA initial state
set_tris_a(0); // All PORTA pins are configured as outputs
output_b(0); // PORTB initial state
set_tris_b(0x1F); // Configure RB0 to RB4 as inputs
pwm_off(); // Turn off all pwm outputs
while(TRUE) {
if(input(PIN_B0) == 0){ // If RB0 button pressed
i++; // Increment i by 1 (i = i + 1)
if(i > 99){
i = 100;
output_high(PIN_B7);} // RB7 LED ON
pwm_set_duty_percent(i * 10UL); // Duty cycle change in tenths %
delay_ms(100); } // Wait 100ms
if(input(PIN_B1) == 0){ // If RB1 button pressed
output_low(PIN_B7); // RB7 LED OFF
i--; // Decrement i by 1 (i = i - 1)
if(i < 1)
i = 1;
pwm_set_duty_percent(i * 10UL); // Duty cycle change in tenths %
delay_ms(100); } // Wait 100ms
if(input(PIN_B2) == 0){ // If RB2 button pressed
if(input(PIN_B5) == 0){
output_low(PIN_B6); // RB6 LED OFF
pwm_off(); // Turn off pwm for both outputs
output_a(0); // PORTA pins low
delay_ms(100); // Wait 100ms
pwm_on(PIN_A0); // Turn pwm on at RA0
output_high(PIN_B5); // RB5 LED ON
if(i > 99)
output_high(PIN_B7);}}
if(input(PIN_B3) == 0){ // If RB3 button pressed
if(input(PIN_B6) == 0){
output_low(PIN_B5); // RB5 LED OFF
pwm_off(); // Turn off pwm for both outputs
output_a(0); // PORTA pins low
delay_ms(100); // Wait 100ms
pwm_on(PIN_A1); // Turn PWM on at RA1
output_high(PIN_B6);
if(i > 99)
output_high(PIN_B7);}}
if(input(PIN_B4) == 0){ // If RB4 button pressed
pwm_off(); // Turn off pwm for both outputs
output_a(0); // PORTA pins low
output_b(0);} // PORTB pins low
}
} |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Mar 18, 2019 2:19 pm |
|
|
simple answer..
select a PIC that actually HAS a CCP internal peripheral.
If I recall the F84 is the flash newborn of the C84 , and they never had a CCP, just I/O pis and a single timer.
Download the datasheet to confirm/deny what I say...
also check the CCS manual for the #USE PWM(...) options and usage, probably says what's valid or not..... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Mon Mar 18, 2019 2:32 pm |
|
|
Yes, It was the first chip where MicroChip decided to use the 'F' naming to
signify 'flash'. The C84, also used flash memory. The F84 was a fractionally
enhanced version of this.
Over 20 year old chip.
You need a chip with the CCP, or ECCP, to use PWM. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Mar 18, 2019 3:17 pm |
|
|
He's using the very old 5.015. I compiled it with vs. 5.083 and it worked:
Quote: | Executing: "C:\Program Files (x86)\PICC\Ccsc.exe" +FM "PCM_test.c" +DF +LN -T -A +M -Z +Y=9 +EA #__16F84A=TRUE
Compiling C:\Users\Home\Documents\PICC\Projects\PCM_test\PCM_test on 18-Mar-19 at 14:15
--- Info 300 "C:\Users\Home\Documents\PICC\Projects\PCM_test\PCM_test.c" Line 6(1,1): More info:
PWM period: 2.00 ms, Frequency: 500.000 Hz, Resolution: 7.97 bits,
Maximum duty: 96.00%, Minimum duty: 4.00%
Memory usage: ROM=47% RAM=28% - 50%
0 Errors, 0 Warnings.
Build Successful.
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Tue Mar 19, 2019 5:10 am |
|
|
OK, I'm confused....maybe it's OTM ( Old Timer's Moment)..
Since the code compiled for PCMP, I have to assume a software PWM was created...yet the OP has 'FORCE_HW' which isn't in the manual I have. As I type, I'm thinking that option, would it can create a SW PWM... but without a CCP, I'd expect the compiler to halt due to the error (F84 has no CCP).
#USE PWM() in my copy of the manual doesn't state 'can be used to create a SW PWM' and 'force-hw' isn't listed either.
curious..
tried under 5.021, compiler didn't like it...
so 'somewhere after 21' it'll work.
sad thing is it seemed like yesterday I was AMAZED the 'F'lash version had been made ! No more 15 minute coffee breaks while the UV eraser did it's thing...
Jay
Last edited by temtronic on Tue Mar 19, 2019 12:46 pm; edited 1 time in total |
|
|
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
|
|
Posted: Tue Mar 19, 2019 9:26 am |
|
|
I noticed the FORCE_HW as well.
But as PCM Programmer pointed out, this is a quite old version of the compiler.
The thing is, the code looks copied line for line from the source, which is included in the opening comment. I'm assuming that should have compiled. I have nothing to test with, but I suspect it could be compiler version. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Mar 19, 2019 12:29 pm |
|
|
I finally located my 16F84A-20 PIC and tested it just now on a
PICdem2-plus board (old style). It works. It's obviously ignoring the
FORCE_HW. I changed the crystal frequency and LED pins to fit my board.
If I set duty = 10, I get dimly lit LEDs on pins B0 and B1.
If I change it to 50% duty, they are decently bright.
I notice it doesn't light up the LEDs with duty = 100.
But it does light them up very brightly if duty = 99.
This was tested with CCS vs. 5.083.
Code: |
#include <16F84A.h>
#fuses XT, NOWDT, PUT, NOPROTECT
#use delay(clock = 4M)
#use pwm(output = pin_B0, output = pin_B1, timer = 0, frequency= 500Hz, duty = 10, FORCE_HW)
//=================================
void main()
{
while(TRUE);
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Wed Mar 20, 2019 12:57 am |
|
|
FORCE_HW doesn't exist. This compiler supports hardware only.
Latter versions of the compiler will generate a software PWM on this
chip. His version is complaining that it cannot do this.
However since the posted code want to to use a hardware PWM, the
comment definitely exists that he needs to be using a chip with such
a feature....
The key point is that his 'FORCE_HW' selection, and the chip being used
are 'mutually exclusive'. On a later compiler he can have a software PWM
on this chip. |
|
|
|