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

DSPIC33FJ128GP802

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



Joined: 18 Nov 2009
Posts: 3

View user's profile Send private message

DSPIC33FJ128GP802
PostPosted: Sun Nov 22, 2009 5:27 am     Reply with quote

I am trying to setup RS232 for the DSPIC33FJ128GP802.
I am not able to do it.

I have tried the following options
#use rs232(baud=2400, XMIT=PIN_B8,RCV=PIN_B9,parity=N,bits=8)

also

#use rs232(baud=2400, UART1)
#pin_select U1TX=PIN_B8
#pin_select U1RX=PIN_B9

also tried the above with UART2 1A and 2A .

even tried different baud rates , and printfs in while loops

I have also tried to do that with other pins than b8 and b9.

But I am unable to get printf on the hyperterminal.

My MAX232 and DB9 is well set as I can use that on other microcontroller PIC18F4620 but not getting anything on dsPIC

Can anyone tell what is the problem

I am using the regular fuses and the .h file from the compiler version 4.099
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Nov 22, 2009 7:20 am     Reply with quote

According to the datasheet, U1STA Bit 14 must be set to achieve a standard Tx idle level of '1', which isn't done by PCD. But the documentation may be incorrect. Can you check the Tx pin level? It should be high at the processor and low (-12 V) at the MAX232 output.
mihir



Joined: 18 Nov 2009
Posts: 3

View user's profile Send private message

PostPosted: Mon Nov 23, 2009 5:33 pm     Reply with quote

I checked the voltages on the TX pin on the controller I am getting 3.9V and 5V on the RX pin.

On the interface from MAX232 to DB9 I am getting negative 5V at the RX pin but getting a 0V at the TX pin!!

I think that is the problem, but I am not sure how to solve it.

Also to let you know that when I use the same MAX232 with the same set of connection with a 18Fxx series it works well and get printf on RS232.

Is it something to do with the Fuses?

I am copying my code below:
There you can see the different options I tried for the RS232.
When I remove the printfs my remaining code works fine for PWM.
Code:

#include <33FJ128GP802.h>
#fuses none
#use delay(clock=20000000)

//#pin_select U1TX=PIN_B8
//#pin_select U1RX=PIN_B9
//#use rs232(UART1 ,baud=2400)
#use rs232(baud=2400, XMIT=PIN_B8,RCV=PIN_B9)

#pin_select OC1=PIN_B3

void main(void)
{
int16 duty;
duty=4000;

output_high(PIN_A1);
output_high(PIN_A0);

printf("working\n\r");

setup_timer2(TMR_INTERNAL|TMR_DIV_BY_1, 0x3E80); //period = 1.6ms

SETUP_COMPARE(1,COMPARE_PWM|COMPARE_TIMER2);

while(TRUE)
{
SET_PWM_DUTY(1,duty);
printf(" PWM ");
}
}


Also I have tried all these fuses
Code:

/*#FUSES NOWDT                    //No Watch Dog Timer
#FUSES ICSP1                    //ICD uses PGC1/PGD1 pins
#FUSES NOJTAG                   //JTAG disabled
#FUSES NOCOE                    //Device will reset into operational mode
#FUSES DEBUG                  //Debug mode for ICD
#FUSES PUT128                   //Power On Reset Timer value 128ms
#FUSES WPOSTS16                 //Watch Dog Timer PostScalar 1:32768
#FUSES WPRES128                 //Watch Dog Timer PreScalar 1:128
#FUSES WINDIS                   //Watch Dog Timer in non-Window mode
#FUSES NOPR                     //Pimary oscillaotr disabled
#FUSES OSCIO                    //OSC2 is general purpose output
#FUSES NOCKSFSM                 //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES FRC_PLL                  //Internal FAST RC oscillator with PLL
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOWRTSS                  //Secure segment not write protected
#FUSES NOSSS                    //No secure segment
#FUSES NORSS                    //No secure segment RAM
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOBSS                    //No boot segment
#FUSES NORBS                    //No Boot RAM defined
#FUSES RESERVED                 //Used to set the reserved FUSE bits
#FUSES NOALTI2C                 //I2C mapped to alternate pins
#FUSES NOIOL1WAY                //Allows multiple reconfigurations of peripheral pins
*/
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