View previous topic :: View next topic |
Author |
Message |
andys
Joined: 23 Oct 2006 Posts: 175
|
pwm for PIC16F1507...PIC16F1507 |
Posted: Sun May 06, 2012 5:10 pm |
|
|
I tried to create pwm (for PIC16F1507...PIC16F1507 ) and I saw that for these micro-controllers the instruction:
Code: |
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);
|
is not working. (For other micro-controller this instruction is working). The datasheet for these micro-controller describe that are provided with pwm.
What is going wrong?????? |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Sun May 06, 2012 5:41 pm |
|
|
What version of CCS are you using? What "other microcontroller"? _________________ Google and Forum Search are some of your best tools!!!! |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sun May 06, 2012 5:43 pm |
|
|
post your CODE that tries to use PWM - all of it
post your compiler version
post your SCHEMATIC that shows how you plan to use the PWM |
|
|
andys
Joined: 23 Oct 2006 Posts: 175
|
|
Posted: Sun May 06, 2012 6:16 pm |
|
|
I am at the process to find the pic so my code is just few instructions to check the pic :
Code: |
#if defined(__PCM__)
#include <16F1507.h>
//#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#elif defined(__PCH__)
//#include <18F2423.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#elif defined(__PCD__)
//#include<30F2010.h>
#fuses HS,NOWDT,NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#endif
void main()
{
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun May 06, 2012 7:24 pm |
|
|
If you believe the compiler has a bug, then always post your compiler
version. A request that you do this is in a "sticky" post by Temtronic
at the top of the forum. Please read this. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon May 07, 2012 7:48 am |
|
|
Code: |
{
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);
|
This is an inadequate amount of setup code.
You have not setup a timer to drive pwm or
set a PWM duty cycle VALUE to generate yet.
Your code is very very incomplete.
Do as PCM says
post your compiler version while you are at it. |
|
|
andys
Joined: 23 Oct 2006 Posts: 175
|
|
Posted: Mon May 07, 2012 9:50 am |
|
|
i use MPLAB v8.83 , and the compiler PCM v4.133d |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon May 07, 2012 10:01 am |
|
|
sorry but i can't help with issues around 4.133
as i am unable to make it run on my system - yet
how did you get your copy ??
|
|
|
andys
Joined: 23 Oct 2006 Posts: 175
|
|
Posted: Mon May 07, 2012 2:46 pm |
|
|
I download the free version (for some days) |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 07, 2012 4:49 pm |
|
|
Quote: | I tried to create pwm (for PIC16F1507...PIC16F1507 ) and I saw that for these micro-controllers the instruction:
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);
is not working.
|
What you really mean is that those lines of code give a compiler error.
They don't compile. You get these errors:
Code: | *** Error 12 "16F1507.c" Line 8(11,12): Undefined identifier -- setup_ccp1
*** Error 12 "16F1507.c" Line 12(14,15): Undefined identifier -- set_pwm1_duty
|
I tested this just now with vs. 4.132, and it doesn't have any support for
the PWM module in the 16F1507. The 16F1507.h file doesn't have any
constants for PWM functions.
It's possible to add support by writing your own PWM functions, similar
to the CCS functions. Or, you can write directly to the PWM registers
in your program. |
|
|
|