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 CCS Technical Support

Using PWM.

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







Using PWM.
PostPosted: Mon Feb 17, 2003 10:41 am     Reply with quote

<font face="Courier New" size=-1>Ihave the following error when trying to compile a program that is using PWM. It is compiler version IDE 3.6 PCM 3.05.

APPLICATION ERROR
Execption Ecerror in module PCM.DLL at 00075734.

Any help would be great. Here is a copy of the program.

// pulse.c
// This is a test to see how the pulse width modulation generator works.

#include <16F877.h>
#fuses xt,nowdt
#use delay(clock=4000000)

void lcd_send_command(int n);
void lcd_send_data(char n);
void pulse_width(int period, int duty);

void main (void)
{
int period, duty;

do{
period = 100;
duty = 50;

// Initialize the LCD
lcd_send_command(0x38); // 2 lines, 5x7 matrix.
lcd_send_command(0x01); // Clear LCD.
lcd_send_command(0x02); // Set cursor to home position.
lcd_send_command(0x0F); // Set cursor blinking.

// PWM
pulse_width(period, duty);

// Display the Period.
lcd_send_data("Period = ");
lcd_send_data(period + 48);

// Display the Duty Cycle.
lcd_send_command(0xC0);
lcd_send_data("Duty = ");
lcd_send_data(duty + 48);
}while(true);


}

void lcd_send_command(int n)
{
output_d(n); // Send a command.
output_low(PIN_B6); // Set Rs=0;
output_high(PIN_B7); // Set E=1;
delay_ms(5); // Delay 5ms
output_low(PIN_B7); // Clear E=0;
delay_ms(10); // Delay 10ms.
}

void lcd_send_data(char n)
{
output_d(n); // Send data to LCD.
output_high(PIN_B6); // Set Rs=1.
output_high(PIN_B7); // Set E=1.
delay_ms(5); // Delay 5ms.
output_low(PIN_B7); // Clear E=0.
delay_ms(10); // Delay 10ms.
}

void pulse_width(int period, int duty)
{
setup_ccp1(CCP_PWM); // Setup for PWM.
setup_timer_2(T2_DIV_BY_1, period, 0);
setup_pwm1_duty(duty);
}</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11792
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Using PWM.
PostPosted: Mon Feb 17, 2003 1:32 pm     Reply with quote

:=Ihave the following error when trying to compile a program that is using PWM.
:=
:=APPLICATION ERROR
:=Exception Error in module PCM.DLL at 00075734.
----------------------------------------------------

What version of the compiler ? They're all different.
___________________________
This message was ported from CCS's old forum
Original Post ID: 11802
Donald
Guest







Re: Using PWM.
PostPosted: Mon Feb 17, 2003 3:10 pm     Reply with quote

:=:=Ihave the following error when trying to compile a program that is using PWM.
:=:=
:=:=APPLICATION ERROR
:=:=Exception Error in module PCM.DLL at 00075734.
:=----------------------------------------------------
:=
:=What version of the compiler ? They're all different.

--------------------------------------------------------
It is IDE version 3.6 PCM 3.05
___________________________
This message was ported from CCS's old forum
Original Post ID: 11808
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Using PWM.
PostPosted: Mon Feb 17, 2003 3:48 pm     Reply with quote

<font face="Courier New" size=-1>:=:=:=Ihave the following error when trying to compile a program that is using PWM.
:=:=:=
:=:=:=APPLICATION ERROR
:=:=:=Exception Error in module PCM.DLL at 00075734.
:=:=----------------------------------------------------
:=:=
:=:=What version of the compiler ? They're all different.
:=
:=--------------------------------------------------------
:=It is IDE version 3.6 PCM 3.05

=========================================================
You mean vs. 3.050. Well, it's most likely a problem
with the compiler. You got one of CCS's "interim" versions
in which they introduced a temporary bug. See the following
partial list, taken from their old versions page.

3.052 SET_TRIS_D and E were broke in 3.050,3.051 now restored
3.052 In some cases an exception appeared instead of a syntax error - Now fixed

I don't know how you can fix this without upgrading.
As a work-around, any time you get an exception, assume
that it's caused by syntax error. Use /* */ comments
to comment out blocks of code until the exception goes
away. Then find the exact line by using // comments.

With regard to the program you posted, here are two lines
that caused a syntax error when I compiled it.

The problems were:

1. The postscale parameter can be 1-16, not 0-15.
This is documented in the manual.

2. The function is called set_pwm1_duty(), not "setup...".


void pulse_width(int period, int duty)
{
setup_ccp1(CCP_PWM); // Setup for PWM.
setup_timer_2(T2_DIV_BY_1, period, 1); // Was 0
set_pwm1_duty(duty); // Was setup_pwm1_duty(duty)
}

------
One more thing -- I noticed that you don't have NOLVP in
your fuses statement. If you're using a LVP programmer,
that's OK. But if you're using a normal programmer,
such as PicStart-Plus, Warp-13a, etc., then you should
add NOLVP to your #fuses statement.

</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11812
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