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

Software Uart Problem

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



Joined: 20 Oct 2006
Posts: 23

View user's profile Send private message

Software Uart Problem
PostPosted: Wed Mar 07, 2007 2:33 pm     Reply with quote

I am using PIC18F452
Now I try 1 HW UART and 1 SW UART but SW UART doesn't work,I need to use INT signal on it.

Do you think about this solution?
Code:

#include<18f452.h>

#use rs232(stream=CH1,baud=9600,xmit=PIN_C6,rcv=PIN_C7)  //HW UART
#use rs232(stream=CH2,baud=9600,xmit=PIN_B1,rcv=PIN_B0,FORCE_SW)//SW UART

short int hook_rx=0;
short int hook_rx2=0;

#INT_RDA //Interupt Rx routine
void RxD_ISR(void){
      char ch;
      ch = getc();
                     hook_rx=0;

}
#INT_EXT//Rx2 INT routine

void RxD2_ISR(void){
      char ch;
      ch = getc();
                     hook_rx2=0;
}



Are this solution must be set tris_b for B1=output and B0=Input ,Are not?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 07, 2007 2:39 pm     Reply with quote

When you streams, you need to use the CCS functions that allow you
to specify the stream. Instead of getc(), you should use fgetc(stream),
and enter the stream as the parameter. Do this for all rs232 functions
when you use streams.


Also, just use standard i/o (the default mode) and let the compiler
handle setting the TRIS.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Mar 07, 2007 2:47 pm     Reply with quote

Also -assuming that your hardware is ok- you will need to include this statements
in the init:

ext_int_edge(H_TO_L);
enable_interrupts(INT_EXT);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);


Humberto
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