|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
|
Posted: Thu Jul 22, 2004 5:51 am |
|
|
yes.
and BTW, when I run sample grogram from Mikro who sell the easy2 board, it is working, and I can see output in hyperterminal. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jul 22, 2004 6:03 am |
|
|
What speed is your crystal? |
|
|
Guest
|
|
Posted: Thu Jul 22, 2004 6:14 am |
|
|
20MHz |
|
|
Ttelmah Guest
|
|
Posted: Thu Jul 22, 2004 6:34 am |
|
|
Anonymous wrote: | I connected com1 with RS232 port on my PICeasy2 board, and RX was connected with RC7, TX was connected with RC6? |
You do realise you need an inverter (preferably a proper RS232 one), on the signal lines. Otherwise data just like you are seeing will be the result.
RS232, is a (relatively) 'high voltage' signalling standard, using (nominally) +/-15v at the transmitter, with a '1' being received as a voltage below -3v, and a '0', being a voltage above +3v. Many receivers will 'work' off TTL levels, but the signals still need to be inverted. The PIC expects to be connected to such an inverting driver, and hence sends a '1' as +5v and a '0' as 0v.
Best Wishes |
|
|
Guest
|
|
Posted: Thu Jul 22, 2004 6:51 am |
|
|
what kinds of inverter do you think I need? and By the way, when I run the sample hex file from the Mikro, it do send good data in the hyperterminal, and the board already have a max232 built in. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jul 22, 2004 7:23 am |
|
|
The Max232 is what he is referring to. |
|
|
Guest
|
|
Posted: Thu Jul 22, 2004 7:31 am |
|
|
so, I fell frustrate, I have all the hardware ready, and could not find anything wrong with my program, still looking for why? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jul 22, 2004 7:34 am |
|
|
Quote: |
I connected com1 with RS232 port on my PICeasy2 board, and RX was connected with RC7, TX was connected with RC6?
|
RC7 should be connected to the Tx of the PC
and
RC6 should be connected to the Rx of the PC |
|
|
Guest
|
|
Posted: Thu Jul 22, 2004 7:42 am |
|
|
Thank you:
in the program the definition is
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
does that mean
Quote: |
RC7 should be connected to the Tx of the PC
and
RC6 should be connected to the Rx of the PC
|
however I thought it should be
Quote: |
I connected com1 with RS232 port on my PICeasy2 board, and RX was connected with RC7, TX was connected with RC6?
|
Is this the place messed up? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jul 22, 2004 8:22 am |
|
|
RC6 on the PIC is the transmit. If you want to receive data then you must connect it to the RX of another serial port. The same holds true for RC7.
How are you connecting it to the computer? A cable? Straight through or Null modem?
On the EasyPic board, what pin of the DB9 does RC6 connect to?
Do you also have a ground connected? |
|
|
Guest
|
|
|
Guest
|
|
Posted: Thu Jul 22, 2004 8:49 am |
|
|
Hi everybody:
Thank you! Thank you so much. I appreciate your help, expercially Mark, keep communication with me. I find out the reason, It was the crystal speed, it should be 4MHz, however I used 20Mhz. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jul 22, 2004 9:26 am |
|
|
Quote: |
#if defined(__PCM__)
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
//I connected RX to RC7, TX to RC6
void main() {
BYTE value;
int val1;
setup_port_a(ALL_ANALOG);
setup_adc( ADC_CLOCK_INTERNAL );
do {
set_adc_channel( 1 );
delay_us(50);
val1 = Read_ADC();
printf("%u\r\n",val1);
delay_ms(1000);
} while (TRUE);
}
|
You posted this as your test file. According to this you should have to use a 20MHz crystal.
The DB9 is the serial connector on your board.
Glad you got it working. |
|
|
Guest
|
|
Posted: Thu Jul 22, 2004 11:27 am |
|
|
I figure out with all these guys help to see the data on hyperterminal, this is half step forward.
Right now, I need to received data in my vc++.net program.
When I sen data like
putc('A');
I could get the result
by using the following program
Code: |
if(m_comm.get_CommEvent()==2)
{
VARIANT in_dat;
// in_dat=m_comm.GetInput();
unsigned char in_datanum=0;
in_dat=m_comm.get_Input();
in_datanum=in_dat.bVal;
CString strInput(in_dat.bstrVal);
m_input=strInput;
m_input1=in_datanum;
UpdateData(FALSE);
}
|
'A' could be display correctly in editbox m_input, however m_input1 which show it as a BYTE did not show correctly. when I used
printf("%u",val1);
which val1 is a BYTE;
I could not recevie correct right data, why?
if I want to send and receive multiple data, I could send them as
printf(%u%u%u",val1,val2,val3);
how to receive the data and separate them into three separate parameters?
thanks |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jul 22, 2004 1:07 pm |
|
|
Stick something in between the values
Code: |
printf("%u %u %u",val1,val2,val3);
printf("%u,%u,%u",val1,val2,val3);
|
As for your VC not working...
The data is already in ASCII. Think of each byte coming in as a character. The val1 is converted to a string with the printf command. So if val1 = 123 then 49 50 51 will be sent with the printf. 49 is the asc value for '1' and so forth. |
|
|
|
|
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
|