View previous topic :: View next topic |
Author |
Message |
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Tue Mar 09, 2021 9:26 am |
|
|
PCM programmer wrote: | Denny9167 wrote: |
I’m having same problem with code as-is,
It may have worked using an older version of CCS, but not
with newest, which I have.
I followed some of your suggestions, by adding them to the MAIN:
setup_ccp1(CCP_PWM);
setup_timer_2(T2_DIV_BY_1,209,1);
Got a successful build, 0=errors,0=warnings
|
If you had to add those two lines to get a successful build, then you don't
have the newest version of the compiler, which is vs. 5.103. You can see
the version that you have by looking at the top of the .LST file.
Code: |
CCS PCM C Compiler, Version 5.103, xxxxx 08-Mar-21 22:42
Filename: C:\...\Projects\PCM_Test\PCM_TEST.lst
ROM used: 295 words (14%)
Largest free fragment is 1753
RAM used: 6 (5%) at main() level
23 (18%) worst case
Stack used: 2 locations
Stack size: 16 |
I didn't change anything in the code you posted, and it compiled fine with
vs. 5.103. Here is a link to your post:
http://www.ccsinfo.com/forum/viewtopic.php?t=58717&start=8 |
I have v5.103, just purchased it last weekend. Anyway I’m going to try and purchase a logic analyzer as well to help in testing. I hope you’ll be patient with me, I’m an old analog guy, work mostly with vacuum tubes, so much of this digital stuff is new to me, I have learned a lot in the last few months though.
Last edited by Denny9167 on Tue Mar 09, 2021 11:02 am; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue Mar 09, 2021 9:30 am |
|
|
Well done,
5.008, was a bit of an 'ouch'. V5, was 'beta at best' at that point, which
explains a lot of the problems.
Hopefully things will move forwards a little now. ![Very Happy](images/smiles/icon_biggrin.gif) |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Mar 09, 2021 11:53 am |
|
|
My advice is to look at the .LST file to confirm that vs. 5.103 was installed
and is being used to compile code.
Make sure that vs. 5.008 was uninstalled, or at least is not active.
- Press the Start button in Windows
-- Click on Programs
--- Click on PIC-C
---- Click on Compiler Versions - it should say 5.103
----- Click the Other Versions button - Is 5.008 still installed ?
If it shows 5.008 is still there, it will give you the option to remove it. |
|
![](templates/subSilver/images/spacer.gif) |
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
![](templates/subSilver/images/spacer.gif) |
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Wed Mar 10, 2021 4:46 am |
|
|
It seems the directive, “PWM_OFF” in #use , needs to be changed to “disable_level=low” instead??
So that when “pwm_off” function is called , the pins
Being used, are driven low? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 10, 2021 9:48 pm |
|
|
Yes, and then you can use these functions to change the PWM:
pwm_set_duty_percent()
pwm_set_frequency()
pwm_set_duty()
pwm_on()
pwm_off()
The program you posted uses this method. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 10, 2021 10:28 pm |
|
|
Denny9167 wrote: | It seems the directive, “PWM_OFF” in #use, needs to be changed to “disable_level=low” instead??
|
I don't see that parameter listed in the CCS manual for #use pwm()
or in the ccsc.chm help file for vs. 5.103. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Thu Mar 11, 2021 1:52 am |
|
|
You seem to be trying to make this difficult.
Understand that when 'PWM_OFF' is selected, the actual peripheral
is disabled. The level the line then goes to depends on what output
instructions have latched to the registers.
The reason it is not compiling with PWM_OFF, is simple. Your compiler
version did not support this option. Simply look in the manual with
your compiler. You will find the #USE PWM, does not list any such option.
Much simpler to let the PWM drive the pin:
Just use:
#use pwm (PWM1, FREQUENCY = 38KHz, DUTY = 0)
This then enables the PWM peripheral, with the output set low. Just
what you want.
Then when you want to enable/disable the PWM, instead use:
set_pwm_duty_percent(25); //will enable the PWM output with 25% duty.
and
set_pwm_duty_percent(0); //will set the output low.
You have to use the options that are actually available with the compiler
you have. |
|
![](templates/subSilver/images/spacer.gif) |
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Thu Mar 11, 2021 8:30 am |
|
|
Ttelmah wrote: | You seem to be trying to make this difficult.
Understand that when 'PWM_OFF' is selected, the actual peripheral
is disabled. The level the line then goes to depends on what output
instructions have latched to the registers.
The reason it is not compiling with PWM_OFF, is simple. Your compiler
version did not support this option. Simply look in the manual with
your compiler. You will find the #USE PWM, does not list any such option.
Much simpler to let the PWM drive the pin:
Just use:
#use pwm (PWM1, FREQUENCY = 38KHz, DUTY = 0)
This then enables the PWM peripheral, with the output set low. Just
what you want.
Then when you want to enable/disable the PWM, instead use:
set_pwm_duty_percent(25); //will enable the PWM output with 25% duty.
and
set_pwm_duty_percent(0); //will set the output low.
You have to use the options that are actually available with the compiler
you have. |
Thank you, and please excuse my ignorance. I downloaded the manual for
The version of the compiler, and I’ve been studying it. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Thu Mar 11, 2021 8:37 am |
|
|
The manual does have to be your biggest reference. Unfortunately, things do
change, so commands that can be used on the latest compilers often don't
exist on older versions. Your compiler is very old (something like 9 years),
and if you start using more complex chips you may find quite a few
things don't work. To put it in perspective, I only keep compilers that
worked well enough to actually be used at the time. I did not keep 5.008,
since there were some really major issues with it (fixed about 5.012ish).
However the lack of PWM_OFF as an option is still there in this later manual... |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 11, 2021 8:47 am |
|
|
Ttelmah, in an earlier post he says this:
Denny9167 wrote: |
I have v5.103, just purchased it last weekend.
|
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Thu Mar 11, 2021 9:07 am |
|
|
I know. He said this, but is still having issues that are specific to 5.008.
Which compiler he is actually using I don't know. He then also finds
commands that are not part of CCS....
However to have the pin actually drive low, when the signal is stopped,
the best way to go is to just set the duty to zero, since this leaves the
PWM peripheral connected and driving the pin low. ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 11, 2021 9:15 am |
|
|
I told him in a previous post how to find his currently installed version
but he never replied to it.
I agree about the PWM. The program that he found on the net wrongly
uses pwm_off() to do this. He needs to edit the program. |
|
![](templates/subSilver/images/spacer.gif) |
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Thu Mar 11, 2021 11:13 am |
|
|
PCM programmer wrote: | I told him in a previous post how to find his currently installed version
but he never replied to it.
I agree about the PWM. The program that he found on the net wrongly
uses pwm_off() to do this. He needs to edit the program. |
I purchased the $99.00 compiler, the C Workshop, in the about it says v5.103 |
|
![](templates/subSilver/images/spacer.gif) |
Denny9167
Joined: 15 Feb 2021 Posts: 49
|
|
Posted: Thu Mar 11, 2021 11:18 am |
|
|
Im wanting to build my own remote I/O(RCA) with a motorized volume control and
I saw this project using NEC protocol and the code looked easy enough to change for relays and change the output functions in the RX code.
I saw another project that uses the RC5 protocol that I will also try
If I can’t get this one going. I would simply hire someone to do this for me
But finding pic programmers to do the code is tough! |
|
![](templates/subSilver/images/spacer.gif) |
|