View previous topic :: View next topic |
Author |
Message |
boham
Joined: 12 Mar 2008 Posts: 5
|
ASCII from PIC |
Posted: Wed Apr 02, 2008 6:07 pm |
|
|
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
|
|
Posted: Wed Apr 02, 2008 6:26 pm |
|
|
Level converters? |
|
|
boham
Joined: 12 Mar 2008 Posts: 5
|
|
Posted: Wed Apr 02, 2008 6:29 pm |
|
|
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
|
|
Posted: Wed Apr 02, 2008 9:28 pm |
|
|
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
|
|
Posted: Thu Apr 03, 2008 1:16 am |
|
|
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
|
|
Posted: Thu Apr 03, 2008 1:19 am |
|
|
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 |
|
|
|