KenG
Joined: 11 Oct 2010 Posts: 4
|
PWM disables the uart. |
Posted: Mon May 05, 2014 7:41 pm |
|
|
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;
}
}
}
} |
|