View previous topic :: View next topic |
Author |
Message |
drkome
Joined: 26 Dec 2024 Posts: 7
|
DSPIC30F4011 RS232 random character problem. |
Posted: Thu Dec 26, 2024 12:16 pm |
|
|
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
|
|
Posted: Thu Dec 26, 2024 12:28 pm |
|
|
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
|
DSPIC30F4011 RS232 random character problem. |
Posted: Thu Dec 26, 2024 12:40 pm |
|
|
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
|
|
Posted: Thu Dec 26, 2024 1:22 pm |
|
|
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
|
|
Posted: Thu Dec 26, 2024 3:28 pm |
|
|
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
|
DSPIC30F4011 RS232 random character problem. |
Posted: Fri Dec 27, 2024 12:01 am |
|
|
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. |
|
|
|