CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problems with Power_PWM at PIC18F2331

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Eisenlohr



Joined: 22 Feb 2005
Posts: 1

View user's profile Send private message

Problems with Power_PWM at PIC18F2331
PostPosted: Tue Feb 22, 2005 7:20 pm     Reply with quote

I have a compiler Problem by application with 3 of the Power_PWM outputs.

The code is as following:

//declatation and setup
void setup_pwm()
{
setup_power_pwm_pins (pwm_odd_on, pwm_odd_on, pwm_odd_on, pwm_odd_on);
setup_power_pwm (pwm_clock_div_4 | pwm_free_run, 1, 10000, 1023, 0, 1, 0);
return ;
}
...

void main () //begins with main program
{
...
setup_pwm(); //initializes the pwm
init_timer_1 ();
...
while (true) //main loop
{
...

{ //critical part !
set_power_pwm0_duty (0); //setting values for the duty
set_power_pwm2_duty (1024); //4095 is 100% duty
set_power_pwm4_duty (2048); //0 is 0% duty
} //critical part !

...
} //end while
} //end main


The 3 PWM's are functions good by having this code.

But when some code is before the critical part or the both brackets "{" "}" are not in this way, the outputs of the power_pwm's have no function. For example like this:

...
if (true) //must always on
{ //critical part !
set_power_pwm0_duty (0); //setting values for the duty
set_power_pwm2_duty (1024);
set_power_pwm4_duty (2048);
} //critical part !
...

I think the compiled code in the ROM is shiftet in an other position or area an the power_pwm hardware isn't able to functions as well. Then the code wouldn't allocatable in various ROM-spaces. All ideas what I have had are done, but no success. The mistake isn't systmatical so my idea is close to think it must be a genaeal compiler mistake with the POWER_PWM.

Please help me according to my problem.
Is it possible to get some code examples or example files about power_pwm ?

My conditions are: CCS Compiler Rev. 3.219 (actual), MPLAB 6.60, Emulator ICE2000, Xtal=24MHz HS, 5V=Vss.

Thank You
Joerg, Germany
bluetooth



Joined: 08 Jan 2005
Posts: 74

View user's profile Send private message

PostPosted: Wed Feb 23, 2005 6:12 am     Reply with quote

Joerg:

You didn't really supply enough info to give you a specific answer, so I suggest you get out the data sheet. Study the Power Control Module registers to see if they're being set up properly (particulary, what's different from when they work before you put "some code" before the critical function).

Registers of particular interest:

PTCON0
PTCON1
PTPERL
PTPERH
PWMCON0
PWMCON1

Also, check to see if the FLT inputs are enabled and driven - this will shut down your outputs fast! If this is the case, either fix the input problem or disable the FLT input(s) (bad idea) .

-------------- Soap box:

In terms of using the CCS built-in functions: the words of an old politician come to mind: "Trust, but verify". If you're going to use them, it's a REALLY good idea to check the registers to make sure they've got the right number in them at the right times. This is especially true for newer parts. Many users here set up all the registers themselves to avoid this (potential) additional layer of system debug. Personally, I use only the simplest of those functions (#USE RS-232, spi_write/read, a/d functions, etc.) for just that reason.

Good luck....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group