|
|
View previous topic :: View next topic |
Author |
Message |
sindyvirgo
Joined: 15 Jan 2009 Posts: 8
|
How can I set two hardware uart of 18F63J11 |
Posted: Sun Aug 09, 2009 9:26 pm |
|
|
Hello ! everybody.
My 18F63J11 work now but it have two uart.
I discovered that they will snatch the resources mutually.
When the word string surpasses 5 that my terminating machine has exceptionally.
How can I set two hardware uart of 18F63J11 ?
Help me please.
Code: |
#include <string.h>
char buff1,buff2;
#int_RDA
RDA_isr(void)
{
buff1 = getc();
printf("%c",buff1);
}
#int_RDA2
RDA2_isr(void)
{
buff2 = getc();
printf("%c",buff2);
}
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_RDA);
enable_interrupts(INT_RDA2);
enable_interrupts(GLOBAL);
delay_ms(200);
output_high(pin_b0); <---- This my work LED. It have work now.
for(;;)
{
printf("Testing..."); <--- Can't runing
delay_ms(300);
}
} |
My .H file
Code: |
#include <18F63J11.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //External Clock with SW enabled 4x PLL
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOXINST
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOPROTECT //Code not protected from reading
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES PRIMARY
#FUSES RESERVED
#use delay(clock=8000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#use rs232(baud=9600,parity=N,xmit=PIN_G1,rcv=PIN_G2,bits=8)
|
|
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1937 Location: Norman, OK
|
|
Posted: Sun Aug 09, 2009 9:36 pm |
|
|
Add a stream definition to each of the USE RS232 definitions and then add the stream names to each of the getc() putc() and printf() commands. Search for stream in the CCS manual for information on the format of the commands. Also, look at the message next to this one titled "undefined identifier STREAM_UART" for info as well.
BTW, using printf() in the ISR is likely to cause problems at some point due to spending too much time in the ISR.... _________________ Google and Forum Search are some of your best tools!!!! |
|
|
sindyvirgo
Joined: 15 Jan 2009 Posts: 8
|
|
Posted: Sun Aug 09, 2009 10:45 pm |
|
|
Hello everybody.
18F63J11 have two hardware uart.
I set the stream for uart(A) and uart(B) , but still could not the normal work.
When the word string surpasses 5 that my terminating machine still has exceptionally.
It can work but is not normal.
.H file
Code: | #include <18F63J11.h>
#device adc=8
#FUSES NOWDT
#FUSES WDT128
#FUSES HS
#FUSES NODEBUG
#FUSES NOXINST
#FUSES STVREN
#FUSES NOPROTECT
#FUSES FCMEN
#FUSES IESO
#FUSES PRIMARY
#FUSES RESERVED
#use delay(clock=8000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,STREAM=COM_A)
#use rs232(baud=9600,parity=N,xmit=PIN_G1,rcv=PIN_G2,bits=8,STREAM=COM_B)
|
my main .C
Code: |
char buff1,buff2;
#int_RDA
RDA_isr()
{
disable_interrupts(INT_RDA2);
buff1 = getc(COM_A);
}
#int_RDA2
RDA2_isr()
{
disable_interrupts(INT_RDA);
buff2 = getc(COM_B);
}
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_RDA);
enable_interrupts(INT_RDA2);
enable_interrupts(GLOBAL);
delay_ms(200);
output_high(pin_b0); <--- 63J11 work LED
for(;;)
{
fprintf(COM_A,"Testing1..."); <----can't running
fprintf(COM_A,"%c",buff1);
delay_ms(300);
fprintf(COM_B,"Testing2..."); <----can't running
fprintf(COM_B,"%c",buff1);
delay_ms(300);
}
} |
|
|
|
|
|
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
|