View previous topic :: View next topic |
Author |
Message |
soulweed
Joined: 20 Oct 2006 Posts: 23
|
Software Uart Problem |
Posted: Wed Mar 07, 2007 2:33 pm |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 07, 2007 2:39 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Mar 07, 2007 2:47 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|