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

Problem generating PWM signals with PIC18F46J11

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



Joined: 16 Nov 2009
Posts: 6

View user's profile Send private message

Problem generating PWM signals with PIC18F46J11
PostPosted: Wed Nov 18, 2009 9:02 am     Reply with quote

Hello All,

I'm currently trying to generate PWM signals from my PIC18F46J11 processor. I had to install the latest version of the compiler (4.099) since previous versions didn't support this processor type.

I'm using the following code sequence to generate the PWM signals:
Code:

#include <18F46J11.h>

#FUSES NOWDT       
#FUSES HS

#use delay(clock=8000000)

void main()
{
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DIV_BY_16,249,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_timer_4(T4_DISABLED,0,1);

   setup_ccp1(CCP_PWM);
   set_pwm1_duty(972);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
      
   while(1);
}



The code compiles fine but I do not see the signals on my scope!
Also, it is not clear to me on which pins I should see the signals. I've never worked before with a microcontroller with Peripheral Pin Select possibilities. I couldn't find a function inside the CCS compiler help file that shows me how to control the Peripheral Pin Select.

Any ideas/suggestions maybe?
Thanks...
noxus



Joined: 16 Nov 2009
Posts: 6

View user's profile Send private message

PostPosted: Wed Nov 18, 2009 10:15 am     Reply with quote

Never mind - I got it working.

As I suspected it had something to do with the Peripheral Pin Select registers.
Apparently you first have to use the #pin_select function=pin_xx statement to effectively assign the PWM function to the configurable pin.

I added the following statement to my code:
Code:
#pin_select P1A=PIN_C4

Now it is working as expected.
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