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

ASCII from PIC

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



Joined: 12 Mar 2008
Posts: 5

View user's profile Send private message

ASCII from PIC
PostPosted: Wed Apr 02, 2008 6:07 pm     Reply with quote

I have a radio that accepts ASCII as commands to do whatever I need to do with it. Using hyperterminal, it works great. When I tried to use a PIC to send a command, I get garbage on the hyperterminal from one radio connected to the PIC to the other radio connected to the computer with hyperterminal.

Obviously, I'm missing something here. Any takers?

Code:
void main() {
   while(TRUE){
      //If the button is pushed, write
      if (!input(PUSH_BUTTON)){

         //ATDM command,Address,Identifier
         printf("ATDM,00A096141292,1101\r\d");

         delay_ms(1000);      //delay
      }//if

   }//while

What is returned is alot of garbage.[/code]
Guest








PostPosted: Wed Apr 02, 2008 6:26 pm     Reply with quote

Level converters?
boham



Joined: 12 Mar 2008
Posts: 5

View user's profile Send private message

PostPosted: Wed Apr 02, 2008 6:29 pm     Reply with quote

I'm not sure what you mean by level converters...

Here's what I'm playing with.

PIC18F4520
BlueRadios Class 1 Bluetooth module.

Please note, I am not trying to display on hyperterminal from PIC. The radio must receive ascii characters for its commands; Therefore, my output from the PIC must be ASCII.
Guest_7068
Guest







PostPosted: Wed Apr 02, 2008 9:28 pm     Reply with quote

The compiler will output ASCII characters when you specify a string, so your code should work as is. Since you have a radio communication, is the RX line on receiver held high in idle to detect the start bit?
Is your #use rs232 setup correctly?
Are you able to see any signal on the TX line?
Do the baud rate on the PIC match the one on the
Use something simple like
Code:

while(1)
{
   putc('U');   // This will put a character U on the TX line
}


The character 'U' is a good way to debug, as this will output 0x55 in hex, which is a square wave (01010101).
Run the code and test the TX pin on the PIC. Then look for a signal on the RX line of the receiver.
Matro
Guest







PostPosted: Thu Apr 03, 2008 1:16 am     Reply with quote

Level shifter...
It means that your PC is outputing signals with low = -13V and a high = +13V while your PIC only outputs signal in 0-5V range (even maybe in 0-3.3V).
Did you add a level shifter between PIC and radio like a MAX3232?

Matro.
Matro
Guest







PostPosted: Thu Apr 03, 2008 1:19 am     Reply with quote

Below is a part of CCS help :
Code:

1. The PICĀ® is Sending Garbage Characters.

 

A. Check the clock on the target for accuracy.  Crystals are usually not a problem but RC oscillators can cause trouble with RS-232.  Make sure the #USE DELAY matches the actual clock frequency.

 

B.  Make sure the PC (or other host) has the correct baud and parity setting.

 

C. Check the level conversion.  When using a driver/receiver chip, such as the MAX 232, do not use INVERT when making direct connections with resistors and/or diodes.  You probably need the INVERT option in the #USE RS232.

 

D. Remember that PUTC(6) will send an ASCII 6 to the PC and this may not be a visible character.   PUTC('A') will output a visible character A.



Matro
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