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

PWM disables the uart.

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



Joined: 11 Oct 2010
Posts: 4

View user's profile Send private message

PWM disables the uart.
PostPosted: Mon May 05, 2014 7:41 pm     Reply with quote

When I enable the PWM the Uart quits receiving.

I can't see anything obvious in the list file. Is this a hardware problem?
Any help is appreciated!


// PWM Test
// When PWM is enabled the Uart quits receiving.

#include <33EP64MC202.h>

#FUSES FRC_PLL //Internal Fast RC oscillator with PLL
#FUSES CKSFSM //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOJTAG //JTAG disabled

#FUSES NOPWMLOCK
#fuses OSCIO

#use delay(clock=80Mhz,Internal=7.37Mhz)

void main(){
char x;

// Set the serial port pins
#pin_select U1TX=PIN_B10
#pin_select U1RX=PIN_B11

// PWM module enable
#bit PTEN = getenv("BIT:PTEN")

// Primary Master Time Base Period Register
#word PTPER= getenv("SFR:PTPER")

// Master dutycycle
#word MDC= getenv("SFR:MDC")

// Master Duty Cycle Register Select
#bit MDCS = getenv("BIT:MDCS")

PTPER = 8000; // 10kHz period
MDC = 4000; // 50% duty cycle
MDCS = 1;

#use rs232(baud=115200,UART1, XMIT=PIN_B10, RCV=PIN_B11, BITS=8, parity=N, errors)

printf("Press any key except 1 to see the uart working.\r\n");
printf("Pressing the 1 key enables PWM1 but kills the uart receive somehow.\r\n");

while(1) {
if(kbhit()){
x = getc();

switch(x){

case '0':
// PTEN off
PTEN = 0;
printf("PTEN = %d\r\n",PTEN);

break;

case '1':
// PTEN on
PTEN = 1;
printf("PTEN = %d\r\n",PTEN);

break;

default:
printf("You pressed %c. \r\n",x);
break;

}


}
}
}
KenG



Joined: 11 Oct 2010
Posts: 4

View user's profile Send private message

Fixed!
PostPosted: Tue May 06, 2014 5:16 pm     Reply with quote

CCS had to school me on the obvious(hindsight). When using this module be sure to disable any PWMxH,L pins you do not want as PWM by clearing the enable bits in IOCONx. These pins are enabled by default.
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