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.
Not able to work simultaneously with 2 UARTS of PIC18F67K40
Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40
Hi,
CAn you please attach the minimal project that demonstrates this issue ?
Regards,
Filip.
CAn you please attach the minimal project that demonstrates this issue ?
Regards,
Filip.
Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40
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.
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 73 times
- IvanJeremic
- mikroElektronika team
- Posts: 316
- Joined: 05 Sep 2022 14:32
Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40
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.
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.
Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40
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
===============================================================================================
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
===============================================================================================
-
- Posts: 136
- Joined: 02 Jan 2020 19:00
Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40
Why add all the libraries?..
The necessary ones are added.
The necessary ones are added.
Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40
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
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
-
- Posts: 136
- Joined: 02 Jan 2020 19:00
Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40
Hello,
What's not clear here:
https://download.mikroe.com/documents/c ... ibrary.htm
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;
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 can leave C2 if he is not busy:
sbit RS485_rxtx_pin at RC2_bit;
sbit RS485_rxtx_pin_direction at TRISC2_bit;
Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40
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.
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.
Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40
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.
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.
Not able to work with two UART1 and UART2 of PIC18F67K40 in mikroC pro for pic comiler
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.
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.
Re: How set mikrobus gpio pin in PIC16F1526 to connect PCA9685 via I2C in mikroC Pro for pic compiler
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"
Thank you
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"
Thank you
- Attachments
-
- erro.png (13.76 KiB) Viewed 1071 times
-
- Posts: 136
- Joined: 02 Jan 2020 19:00
Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40
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.
Which were used with easypic_v7_P18F, easypicpro_v7_P18F etc...
I will be glad if I am refuted.
- IvanJeremic
- mikroElektronika team
- Posts: 316
- Joined: 05 Sep 2022 14:32
Re: Not able to work simultaneously with 2 UARTS of PIC18F67K40
Hi,
If you don't have the libraries from the picture below: 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
Regards,
Ivan.
If you don't have the libraries from the picture below: 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
Regards,
Ivan.