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 support@ccsinfo.com

problem I am not able to solve. please take a look

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



Joined: 08 Mar 2006
Posts: 3

View user's profile Send private message

problem I am not able to solve. please take a look
PostPosted: Fri Mar 31, 2006 8:20 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Apr 01, 2006 1:39 am     Reply with quote

Hi wb505,

take a look at fputc(data, port);


gerrit
wb505



Joined: 08 Mar 2006
Posts: 3

View user's profile Send private message

PostPosted: Sat Apr 01, 2006 3:10 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Apr 01, 2006 3:50 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Apr 01, 2006 10:56 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Apr 02, 2006 6:26 am     Reply with quote

You are not very quick in getting the hint do you? Wink

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








PostPosted: Sun Apr 02, 2006 1:33 pm     Reply with quote

Thanks you all! Now I got it. I'll try it.
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