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

pic18f67k40 uart problem ...help !

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



Joined: 12 Dec 2018
Posts: 1
Location: BUSAN/KOREA

View user's profile Send private message

pic18f67k40 uart problem ...help !
PostPosted: Wed Dec 12, 2018 6:05 am     Reply with quote

MCU: 18f67k40

I want to use 3 UARTs.
UART1 and UART2 have no problems.
UART3 has a problem.

Setting UART3 together with the corresponding source causes a problem in UART2 and UART3.

I want to use both UART1, UART2, and UART3.

UART1, UART2, and UART3 are all connected to the hardware pins.

PLZ Help

Code:
------------- xx.h ------------------------
#include <18F67K40.h>         
#device *=16 adc=10
#use delay(clock = 4000000)

#pin_select U1TX = PIN_C6
#pin_select U1RX = PIN_C7
#pin_select U2TX = PIN_G1
#pin_select U2RX = PIN_G2
#pin_select U3TX = PIN_E0
#pin_select U3RX = PIN_E1

#use rs232 (uart1, baud = 9600, ERRORS, STREAM = g_Stream_SP)                     
#use rs232 (uart2, baud = 9600, ERRORS, STREAM = g_Stream_Angle)                 
#use rs232 (uart3, baud = 9600, ERRORS, STREAM = g_Stream_Remote)             

#zero_ram

#FUSES XT

       
#BYTE PORTA = 0x0F89
#BYTE PORTB = 0x0F8A
#BYTE PORTC = 0x0F8B
#BYTE PORTD = 0x0F8C
#BYTE PORTE = 0x0F8D
#BYTE PORTF = 0x0F8E
#BYTE PORTG = 0x0F8F
#BYTE PORTH = 0x0F90


#BYTE TRISAA = 0x0F81
#BYTE TRISAB = 0x0F82
#BYTE TRISAC = 0x0F83
#BYTE TRISAD = 0x0F84
#BYTE TRISAE = 0x0F85
#BYTE TRISAF = 0x0F86
#BYTE TRISAG = 0x0F87
#BYTE TRISAH = 0x0F88


Code:

------------- xx.c ------------------------
#include "xx.h"

#int_rda
void rda_isr()
{
    int8 rx_data;
    rx_data = getch(g_Stream_SP);
}

#int_rda2
void rda2_isr()
{
    int8 rx_data;
    rx_data = getch(g_Stream_Angle);
}

#int_rda3
void rda3_isr()
{
    int8 rx_data;
    rx_data = getch(g_Stream_Remote);     

main()
{
    enable_interrupts(INT_RDA);
    enable_interrupts(INT_RDA2);
    enable_interrupts(INT_RDA3);
    enable_interrupts(global);
   
    set_tris_a(0b00111000);
    set_tris_b(0b00001111);
    set_tris_c(0b10000000);
    set_tris_d(0b00000000);
    set_tris_e(0b11110010);
    set_tris_f(0b00000000);
    set_tris_g(0b00000100);
    set_tris_h(0b00001111);

    SETUP_ADC_PORTS( ALL_DIGITAL );   
    porta = 0x00;
    portb = 0x00;
    portd = 0x00;
    porte = 0x00;
    portg = 0x00;
    portg = 0x00;

   while(1)
   {
        .....
    }
}
temtronic



Joined: 01 Jul 2010
Posts: 9093
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Dec 12, 2018 6:27 am     Reply with quote

while I don't use that PIC...some comments..

you need to post your compiler version...

need some more information to narrow down what's happening.

1) does UART #3 work by itself?

2)does UART #1 and #3 work together ?

3) does UART #2 and #3 work together ?

is it ONLY the combination of all 3 UARTs that it fails ?

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Wed Dec 12, 2018 9:21 am     Reply with quote

Also, what is posted, will cause issues:

1) No closing bracket on the RDA3 handler.
2) No actual way of seeing what has been received.
Data is only being retrieved inside the interrupt handler. If you test this with
a debugger, the processor will be halting inside the handler, so won't be
able to handle the other ports. Result lost data....

There is also a potential issue with the stream names. They really need to
be upper case. Now you don't show whether you use #CASE, but if you
are there will be problems using mixed case stream names.
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