|
|
View previous topic :: View next topic |
Author |
Message |
wb505
Joined: 08 Mar 2006 Posts: 3
|
problem I am not able to solve. please take a look |
Posted: Fri Mar 31, 2006 8:20 pm |
|
|
Two internet development board, A and B, with PIC18F6722 on both. On B board, I remove the transceiver for modem and added one more 232 chip as second rs232 RX2/RX2 port which are using G1 and G2 pins.
I connected A board RS232 RX1/TX1 port which are using C6 and C7 pins, to B board RS232 port RX2/TX2, which are using G1 and G2 pins. I want to use functions in EX_STISR.c to transmit data from B board to A board. What is weird is that, after compilation, the port, the data sent from board B, is always RS232 RX1/TX1 port and port RS232 RX2/TX2 was never used, no matter which code below I used:
// code 1
#int_tbe
void serial_isr() {
putc(t_buffer[t_next_out]);
t_next_out=(t_next_out+1) % T_BUFFER_SIZE;
if(t_next_in==t_next_out)
disable_interrupts(int_tbe);
}
void bputc(char c) {
short restart;
int ni;
restart=t_next_in==t_next_out;
t_buffer[t_next_in]=c;
ni=(t_next_in+1) % T_BUFFER_SIZE;
while(ni==t_next_out);
t_next_in=ni;
if(restart)
enable_interrupts(int_tbe);
// or code 2
#int_tbe2
void serial_isr() {
putc(t_buffer[t_next_out]);
t_next_out=(t_next_out+1) % T_BUFFER_SIZE;
if(t_next_in==t_next_out)
disable_interrupts(int_tbe2);
}
void bputc(char c) {
short restart;
int ni;
restart=t_next_in==t_next_out;
t_buffer[t_next_in]=c;
ni=(t_next_in+1) % T_BUFFER_SIZE;
while(ni==t_next_out);
t_next_in=ni;
if(restart)
enable_interrupts(int_tbe2);
can anyone tell me the reason?
Sorry, it should be EX_STISR.c, changed.
Last edited by wb505 on Sat Apr 01, 2006 11:06 pm; edited 2 times in total |
|
|
Gerrit
Joined: 15 Sep 2003 Posts: 58
|
|
Posted: Sat Apr 01, 2006 1:39 am |
|
|
Hi wb505,
take a look at fputc(data, port);
gerrit |
|
|
wb505
Joined: 08 Mar 2006 Posts: 3
|
|
Posted: Sat Apr 01, 2006 3:10 pm |
|
|
Gerrit wrote: | Hi wb505,
take a look at fputc(data, port);
gerrit |
Yes, fputc works fine, but it can only send one byte a time. What I want to do is sending a bunch of data from board B to board A.
Another problem I have now is that when I use the function in the file EX_SISR.c to receive data on board A, the program hangs even there is no data sending from board B. If I comment the line:
enable_interrupts(int_rda);
the program on board A works just ok. |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Sat Apr 01, 2006 3:50 pm |
|
|
Look at streams and fputc().
What do your #use_rs232 declarations look like?
I think by default, if you don't declare a particular stream in a dual UART situation, the part will use UART1 which is C6 & C7.
John |
|
|
wb505
Joined: 08 Mar 2006 Posts: 3
|
|
Posted: Sat Apr 01, 2006 10:56 pm |
|
|
jecottrell wrote: | Look at streams and fputc().
What do your #use_rs232 declarations look like?
I think by default, if you don't declare a particular stream in a dual UART situation, the part will use UART1 which is C6 & C7.
John |
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=USER, errors)
#use rs232(baud=9600,parity=N,xmit=PIN_G1,rcv=PIN_G2,bits=8,stream=uart_b, errors) |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Apr 02, 2006 6:26 am |
|
|
You are not very quick in getting the hint do you?
People in this forum have the tendency not to give direct answers but to let you do some of the digging yourself, this will give you a learning experience in how to solve this type of problems so next time you will be able to help yourself.
Quote: | Look at streams and fputc(). | You are close, just do what the above hint tells you to do: have another look at the manual for the fputc command and how to use it with streams. |
|
|
Guest
|
|
Posted: Sun Apr 02, 2006 1:33 pm |
|
|
Thanks you all! Now I got it. I'll try it. |
|
|
|
|
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
|