Not able to work simultaneously with 2 UARTS of PIC18F67K40

Fully featured PIC compilers available on Windows, Linux, and macOS.
Post Reply
Author
Message
thameemkj
Posts: 8
Joined: 19 Aug 2023 11:44

Not able to work simultaneously with 2 UARTS of PIC18F67K40

#1 Post by thameemkj » 19 Aug 2023 12:24

Hello,
1) We have a PIC18F67K40 controller. We are trying to work with its UART1 and UART2 simultaneously. But were are not able to do so.
2) Initializing and accessing (read or write) each uart individually will work.
3) But initializing them together and accessing them together don't work.
4) When talked with Microchip support, they said it was working for them simultaneously. And they send a code snippet. But they were
using MPLAB IDE. Which wont help me.
5) I tried the UART_Set_Active() function with appropriate parameters each time before calling UART1 and UART2 functions. But that also
did not work for me.

Kindly looking for a reply,
Thankyou.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40

#2 Post by filip » 22 Aug 2023 14:50

Hi,

CAn you please attach the minimal project that demonstrates this issue ?

Regards,
Filip.

thameemkj
Posts: 8
Joined: 19 Aug 2023 11:44

Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40

#3 Post by thameemkj » 23 Aug 2023 06:18

Hi Filip,
I have attached the test program I'm trying to run. Please note that variables related to rx/tx of uart2 starts with nanopi_rx/nanopi_tx.

Regards,
Thameem.
Attachments
MultipleUartsTest.zip
(733 Bytes) Downloaded 70 times

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40

#4 Post by IvanJeremic » 31 Aug 2023 08:46

Hi,

Try using the uart_set_active function.

UART1_Init(9600); // initialize UART1 module
UART2_Init(9600); // initialize UART2 module

RS485Master_Init(); // initialize MCU as Master

UART_Set_Active(&UART1_Read, &UART1_Write, &UART1_Data_Ready, &UART1_Tx_Idle); // set UART1 active
RS485Master_Send(dat,1,160); // send message through UART1

UART_Set_Active(&UART2_Read, &UART2_Write, &UART2_Data_Ready, &UART2_Tx_Idle); // set UART2 active
RS485Master_Send(dat,1,160); // send through UART2

Regards,

Ivan.

thameemkj
Posts: 8
Joined: 19 Aug 2023 11:44

Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40

#5 Post by thameemkj » 04 Sep 2023 12:22

Hello Ivan,
When I tried the snippet you sent, I was getting the following errors. I tried adding all the libraries shown under library manager including RS485. Even then
I was getting the following errors.

Regards.

===============================================================================================
0 1139 Available RAM: 3540 [bytes], Available ROM: 131072 [bytes]
0 122 Compilation Started multipleuartstest.h
29 1508 Implicit conversion of int to ptr MultipleUartsTest.c
32 1508 Implicit conversion of int to ptr MultipleUartsTest.c
54 123 Compiled Successfully MultipleUartsTest.c
0 127 All files Compiled in 31 ms
0 360 Unresolved extern 'rs485_rxtx_pin_direction' __Lib_RS485.c
0 360 Unresolved extern 'rs485_rxtx_pin' __Lib_RS485.c
0 360 Unresolved extern 'rs485_rxtx_pin' __Lib_RS485.c
0 360 Unresolved extern 'TFT_16bit_RS' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_DataPort_Lo' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_WR' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_RS' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_DataPort_Lo' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_WR' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_RS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_DataPort' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_WR' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_DataPort' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_WR' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_DataPort' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_WR' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_DataPort' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_WR' __Lib_TFT_Defs.c
0 102 Finished (with errors): 04 Sep 2023, 16:41:02 MultipleUartsTest.mcppi
===============================================================================================

AntiMember
Posts: 136
Joined: 02 Jan 2020 19:00

Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40

#6 Post by AntiMember » 05 Sep 2023 12:17

Why add all the libraries?..
The necessary ones are added.

thameemkj
Posts: 8
Joined: 19 Aug 2023 11:44

Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40

#7 Post by thameemkj » 08 Sep 2023 10:57

Hello,
Below are the compiler logs I got when I tried to compile only with required libraries that are RS485 and Peripheral_Pin_Select .
Regards,
Thameem.

0 1 mikroCPIC1618.exe -MSF -DBG -pP18F67K40 -DL -O11111114 -fo64 -N"D:\Thameem\OLED_67k40\1v2\Tests\MultipleUartsTest\MultipleUartsTest.mcppi" -SP"C:\Mikroelektronika\mikroC PRO for PIC\Defs\" -SP"C:\Mikroelektronika\mikroC PRO for PIC\uses\P18\" -SP"D:\Thameem\OLED_67k40\1v2\Tests\MultipleUartsTest\" -IP"C:\Mikroelektronika\mikroC PRO for PIC\uses\P18\" "MultipleUartsTest.c" "__Lib_Math.mcl" "__Lib_MathDouble.mcl" "__Lib_System_xxK40.mcl" "__Lib_Delays.mcl" "__Lib_PPS_6XK40.mcl" "__Lib_UART_Remappable_12345.mcl" "__Lib_RS485.mcl"
0 1139 Available RAM: 3540 [bytes], Available ROM: 131072 [bytes]
0 122 Compilation Started multipleuartstest.h
29 1508 Implicit conversion of int to ptr MultipleUartsTest.c
32 1508 Implicit conversion of int to ptr MultipleUartsTest.c
54 123 Compiled Successfully MultipleUartsTest.c
0 127 All files Compiled in 79 ms
0 360 Unresolved extern 'rs485_rxtx_pin' __Lib_RS485.c
0 360 Unresolved extern 'rs485_rxtx_pin_direction' __Lib_RS485.c
0 360 Unresolved extern 'rs485_rxtx_pin' __Lib_RS485.c
0 102 Finished (with errors): 08 Sep 2023, 15:28:50 MultipleUartsTest.mcppi

AntiMember
Posts: 136
Joined: 02 Jan 2020 19:00

Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40

#8 Post by AntiMember » 08 Sep 2023 16:36

Hello,
What's not clear here:
https://download.mikroe.com/documents/c ... ibrary.htm

Code: Select all

The following variable must be defined in all projects using RS-485 Library: 	Description : 	Example :
extern sfr sbit RS485_rxtx_pin; 	Control RS-485 Transmit/Receive operation mode 	sbit RS485_rxtx_pin at RC2_bit;
extern sfr sbit RS485_rxtx_pin_direction; 	Direction of the RS-485 Transmit/Receive pin 	sbit RS485_rxtx_pin_direction at TRISC2_bit;
You must indicate in your code the pin that you use.
You can leave C2 if he is not busy:
sbit RS485_rxtx_pin at RC2_bit;
sbit RS485_rxtx_pin_direction at TRISC2_bit;

thameemkj
Posts: 8
Joined: 19 Aug 2023 11:44

Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40

#9 Post by thameemkj » 25 Sep 2023 11:38

Hello,

I tried by setting global variables ' RS485_rxtx_pin ' and ' RS485_rxtx_pin_direction '. Now Im not getting any
errors while compiling. But still Im only able to send message to only one UART.

Here I have some doubts. How should I give the pin name ? Because I want to send message to 2 different UARTS.
I tried with pin RC7 because thats the RX1/DT1 pin of my PIC. But I also want to send message to RX2/DT2.

And also as I mentioned in the beginning, Im able to send messages to UART1 and UART2 individually. But they
cannot be initialized and used together.

Thankyou.

kumar123
Posts: 76
Joined: 17 Oct 2023 07:32

Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40

#10 Post by kumar123 » 17 Oct 2023 10:59

Hello,

I am to able to work with simultaneously two UARTS of PIC18F67K40 in mikroC pro for pic.
We have a PIC18F67K40 controller. We are trying to work with its UART1 and UART2 simultaneously. But were are not able to do so.

Kindly looking for a reply,
Thank you.

kumar123
Posts: 76
Joined: 17 Oct 2023 07:32

Not able to work with two UART1 and UART2 of PIC18F67K40 in mikroC pro for pic comiler

#11 Post by kumar123 » 19 Oct 2023 12:28

Hi,
1) I have written this piece of code in mikroC pro for pic compiler.
2) We are trying to work with its UART1 and UART2 simultaneously. But were are not able to do so.
3) Initializing and accessing (read or write) each uart individually will work.
4) But initializing them together and accessing them together don't work.

void main(void) {
UART1_Init(9600);
Delay_ms(100);

UART2_Init(9600);
Delay_ms(100);

RS485Master_Init();

while(1) {
UART_Set_Active(&UART1_Read, &UART1_Write, &UART1_Data_Ready, &UART1_Tx_Idle); // set UART1 active
RS485Master_Send(data_1, 8, 160); // send message through UART1

UART_Set_Active(&UART2_Read, &UART2_Write, &UART2_Data_Ready, &UART2_Tx_Idle); // set UART2 active
RS485Master_Send(data_2, 8, 160); // send message through UART2

Delay_ms(1000);
}
}

Kindly looking for a reply,
Thank you.

kumar123
Posts: 76
Joined: 17 Oct 2023 07:32

Re: How set mikrobus gpio pin in PIC16F1526 to connect PCA9685 via I2C in mikroC Pro for pic compiler

#12 Post by kumar123 » 09 Nov 2023 12:15

Hi,

I want to control servo motor using microcontrollar(PIC16F1526). The microcontrollar is connected to PCA9685 module via I2C.
I have used servo library in mikroC pro for PIC compiler but is not working to control the servo motor.
It is showing "Undeclared Identifier mikrobus_gpioInit"
Image

Thank you
Attachments
erro.png
erro.png (13.76 KiB) Viewed 1039 times

AntiMember
Posts: 136
Joined: 02 Jan 2020 19:00

Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40

#13 Post by AntiMember » 09 Nov 2023 19:30

I think this library will only work with 18X microcontrollers.
Which were used with easypic_v7_P18F, easypicpro_v7_P18F etc...
I will be glad if I am refuted. 8)

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40

#14 Post by IvanJeremic » 10 Nov 2023 08:20

Hi,

If you don't have the libraries from the picture below:
Untitled.png
Untitled.png (13.85 KiB) Viewed 1022 times
Then download the libraries from the link below and choose the MCUs that you are using if they are not already chosen, can't guarantee that it will work if you choose an MCU which was not chosen before but it is worth a shot.
https://libstock.mikroe.com/projects/view/2249/mikrosdk
Untitled.png
Untitled.png (9.26 KiB) Viewed 1022 times
Regards,

Ivan.

Post Reply

Return to “PIC AI compilers”