View previous topic :: View next topic |
Author |
Message |
toneill
Joined: 13 Sep 2024 Posts: 2
|
PIC24EP RS232 Setup Issues |
Posted: Fri Sep 13, 2024 9:00 am |
|
|
Hi,
We are having trouble with the below code. The output of the string is garbage characters, but it is displaying the right number of characters. The characters are repeatedly the same. When we changed the clock speed that changed the output. We tried a pre-existing software on the board we are using and it worked. Any thoughts would be appreciated.
Thanks
Code: | #include <24EP256MC202.h>
#use delay(clock=19,200,000)
#pin_select U1TX = PIN_B11
#pin_select U1RX = PIN_B10
#use rs232(UART1, BAUD=19200)
void main()
{
while(1)
{
printf("hello");
delay_ms(500);
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19451
|
|
Posted: Fri Sep 13, 2024 9:14 am |
|
|
Where is your clock coming from??????
You don't have any setting there to say where to get the clock from.
Why 19.2MHz?.
Code: |
#include <24EP256MC202.h>
#use delay(INTERNAL=19.2MHz) //note keyword here
#pin_select U1TX = PIN_B11
#pin_select U1RX = PIN_B10
#use rs232(UART1, BAUD=19200)
void main()
{
while(TRUE)
{
printf("hello");
delay_ms(500);
}
}
|
It is setting up the code to run at 19.2MHz (since you have specified this as
the clock rate), but is not doing the setup to get this from the internal
oscillator, so assumes you are generating it 'somehow'. Probably running
at
With the setup added, it'lll tell you what the real clock is (should be
about 19.19MH nominal). |
|
|
toneill
Joined: 13 Sep 2024 Posts: 2
|
|
Posted: Fri Sep 13, 2024 10:05 am |
|
|
The clock speed we were using was 132,660,000, because that is what it was set to in the software we are basing it off of. It did not communicate properly so we tried changing the clock speed. 19.2 MHz was what we tried before posting this. We are very new to using PIC processors so we are not entirely sure what we are doing. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19451
|
|
Posted: Sat Sep 14, 2024 4:03 am |
|
|
The same comment applies though, that you are not telling it how to
get this clock.
Just saying 'use this clock speed', does not sat how to generate it. That
is why setups need to say the speed, _and_ where to get the clock from.
The compiler can then do the maths to setup the PLL.... |
|
|
|