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

dspic33ep512mu810 => Serial port connected with PC

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



Joined: 04 Oct 2013
Posts: 3

View user's profile Send private message

dspic33ep512mu810 => Serial port connected with PC
PostPosted: Fri Oct 04, 2013 9:44 am     Reply with quote

Dear all,

I am working with the DSPIC33EP512MU810 and I have this problem: I have tried to configure several times the chip for using the serial RS232 communication having an hyperterminal connected to the PC, but I don´t receive correctly the information. I receive something like this:

þþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþ
þþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþ~ø€  ð~øð€ð~øð ?
<ð€àðàüð€àààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà
ààààààààààààààààààààààààààààààààààààààààðààààààààààààààààààààààààààààðàààààààààà
àààààààààààààààààààààààààààààààààààðààààààààààààààààààààààààààààààààààààààà

I tried using a several very simple code like this:
Code:

#include <33EP512MU810.h>

#use delay(clock=16000000)                        //Frecuencia de trabajo 33EP512MU810

#FUSES NOPROTECT //Code not protected from reading   //33EP512MU810
#FUSES NOWRT //Program memory not write protected   //33EP512MU810
#FUSES FRC                  //Internal Fast RC Oscillator
#FUSES NOPR                     //Pimary oscillaotr disabled
#FUSES NOBROWNOUT               //No brownout reset
#use rs232(baud=38400, xmit=PIN_F3,rcv=PIN_F13,bits=8,parity=N)



void main()

   delay_ms(250);
      while(1)
   {   
      putc('A');               //Transmite el caracter
      delay_ms(1000);            //Temporiza 1 segundo
   }
      
}
Could you help me to solve this problem?

I have tried the communication with other PIC16 and PIC18 and it works OK. Therefore the problem is not the PC.

Thanks in advance
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Fri Oct 04, 2013 11:13 am     Reply with quote

probably wrong clock setup.... most likely your clock is running faster or slower than you think... and thus the baud calculation is off..

sometimes that is done purposedly like when changing clock speeds mid operation... in order to keep the same baud from the PC point of view if you half the PIC clock frequency you double the baud on the UART...

make a proper blinky test... use an O-scope if you have one...
_________________
CCS PCM 5.078 & CCS PCH 5.093
jeremiah



Joined: 20 Jul 2010
Posts: 1345

View user's profile Send private message

PostPosted: Fri Oct 04, 2013 3:03 pm     Reply with quote

Your code indicates that you are using an internal oscillator of 16 MHz. I wasn't able to locate a 16MHz internal in the data sheet and you didn't specify using the PLL in your code.

Is there a 16MHz internal on that chip?
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri Oct 04, 2013 4:07 pm     Reply with quote

The link on Microchip's website:http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en554310 states it has an internal Oscillator of 7.37 MHz or 32.768kHz.

Ronald
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Sat Oct 05, 2013 3:44 am     Reply with quote

Yes. This is a very important thing to 'understand'.

The clock statement in CCS, historically was you telling the chip what speed you were running. Nothing else.

With latter chips, it became a 'double purpose' statement, with you telling the chip what speed you were running, _or_ if using sources with options available, telling the compiler what it should try to setup.

However what it 'can' do is always constrained by what the hardware can do.

Now on the PIC33, the internal oscillator cam be used with a complex PLL/divider chain, too generate a huge range of frequencies. However _only if this is enabled_. Hence Jeremiah's comment.

Without the PLL/divider chain, just two frequencies are available, and neither of these is what you are asking for.

It is a 'pity' that the compiler doesn't issue a warning in this case, but it does tend to assume you _know_ what you are doing....

If you get rid of the oscillator fuse (FRC), and just change the clock statement, to:

#use delay (INTERNAL=16MHz)

Then the compiler (on recent versions), will attempt to setup the clock for you. and will select FRC_PLL, with *35/16 = 16.12MHz, or *17/8 = 15.66125MHz. Without the PLL, the current code will be running at 7.37MHz, and hence the serial problems....

Best Wishes
vallejera



Joined: 04 Oct 2013
Posts: 3

View user's profile Send private message

PostPosted: Sat Oct 05, 2013 7:42 am     Reply with quote

Dear all,

thank you for the information!! It has been very useful!!
Therefore, for working with the internal oscillator and using a frequency of 16MHz, I have to insert this lines in my code:


#include <33EP512MU810.h>
#use delay(internal=16120000)
#FUSES FRC_PLL //Fast RC with PLL


Do it need any other configuration?
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Sat Oct 05, 2013 7:56 am     Reply with quote

The #use delay should set all the correct fuses. Have you checked that your clock are running at the speed that you set as was mentioned earlier.

Regards
vallejera



Joined: 04 Oct 2013
Posts: 3

View user's profile Send private message

PostPosted: Sun Oct 06, 2013 1:04 pm     Reply with quote

Now it is working fine!!!
Thank you very much for your support!!!!
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