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

PIC24EP RS232 Setup Issues

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



Joined: 13 Sep 2024
Posts: 2

View user's profile Send private message

PIC24EP RS232 Setup Issues
PostPosted: Fri Sep 13, 2024 9:00 am     Reply with quote

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: 19539

View user's profile Send private message

PostPosted: Fri Sep 13, 2024 9:14 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Sep 13, 2024 10:05 am     Reply with quote

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: 19539

View user's profile Send private message

PostPosted: Sat Sep 14, 2024 4:03 am     Reply with quote

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....
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