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

DSPIC30F4011 RS232 random character problem.

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



Joined: 26 Dec 2024
Posts: 7

View user's profile Send private message

DSPIC30F4011 RS232 random character problem.
PostPosted: Thu Dec 26, 2024 12:16 pm     Reply with quote

Hi everyone. I try to do RS232 communicate with DSPIC30F4011. I wrote some code and I saw just random ASCII characters. I used the following code. My baudrate value is also correct in terminal.
But the random values ​​are coming from the baudrate or Mhz speed. I am very new to this. Can anyone help? When I set it as internal clock here, doesn't it automatically adjust the baudrate accordingly? I think I have this problem because the Mhz does not match.
Thank you !

Code:
#include<30F4011.h>

#FUSES PROTECT

#use delay(internal = 100Mhz)
#use rs232( baud = 9600, XMIT=PIN_C13,RCV=PIN_C14,STREAM =seriale)





void main (){   
 while(TRUE){
 
   fprintf(seriale,"naber ben kamer");
   output_d(0b0100);
 }   
 }
 
gaugeguy



Joined: 05 Apr 2011
Posts: 306

View user's profile Send private message

PostPosted: Thu Dec 26, 2024 12:28 pm     Reply with quote

Why did you choose an internal=100MHz setting?
Have you looked at the data sheet to determine what settings are possible?
drkome



Joined: 26 Dec 2024
Posts: 7

View user's profile Send private message

DSPIC30F4011 RS232 random character problem.
PostPosted: Thu Dec 26, 2024 12:40 pm     Reply with quote

Someone was teaching me and said that I could set the internal clock in the code to the desired value with the pll. That's it. I want to say something different. If I enter a value below 100 mhz, the compiler gives an error.
Ttelmah



Joined: 11 Mar 2010
Posts: 19589

View user's profile Send private message

PostPosted: Thu Dec 26, 2024 1:22 pm     Reply with quote

It should allow you to select lower frequencies without problems. What
voltage are you actually running off, and how is it smoothed?. The faster
you run the chip the more critical the supply connections and smoothing
become. You need all four grounds and all four power connections
properly made.
Something like:
Code:

#include<30F4011.h>

#use delay(internal = 30Mhz)
#use rs232( baud = 9600, XMIT=PIN_C13,RCV=PIN_C14,STREAM =seriale)

void main (void)
{
   while(TRUE)
   {
      fprintf(seriale,"naber ben kamer");
      output_d(0b0100);
      delay_ms(100);
   }   
}

Will compile and run fine.

What is the actual part number of your device?.. The part _after_ the
4011 on the chip?. If this says -20, then your chip is rated for a maximum
80MHz clock. Also if your supply is 3.3v, then all the chips are rated for
80 or 60MHz only. It may well be the chip just cannot run at the speed
you are trying to select.

What version is your compiler??????
You are using the alternative pins for UART1. On older compilers this will
not work, and you will have to manually select this. You need to set the
ALTIO bit in the U1MODE register.

Repeat ten times. Do NOT turn on code protection, while doing development.
Doing so, wastes time when programming and uses up chip write lives
pointlessly.
dyeatman



Joined: 06 Sep 2003
Posts: 1941
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu Dec 26, 2024 3:28 pm     Reply with quote

Also need to add ERRORS to the #use rs232 line:

Code:
#use rs232( baud = 9600, XMIT=PIN_C13,RCV=PIN_C14,STREAM =seriale, ERRORS)

_________________
Google and Forum Search are some of your best tools!!!!
drkome



Joined: 26 Dec 2024
Posts: 7

View user's profile Send private message

DSPIC30F4011 RS232 random character problem.
PostPosted: Fri Dec 27, 2024 12:01 am     Reply with quote

You tried everything you said and learned extra information. Thank you very much. And I also learned how many questions I had to explain thank you. I will look into the things you said extra.
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