Problem with UART and CPU frequency on PIC18F47K42

General discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
MicA380
Posts: 4
Joined: 22 Nov 2019 20:05

Problem with UART and CPU frequency on PIC18F47K42

#1 Post by MicA380 » 22 Nov 2019 20:22

Hello,
I’m using the compiler version 7.5.0 and now 7.6.0 , 18F47K42 processor and I have some problems that I can't solve.

1. I use UART1 and UART2 , here is the problem (only sending data):

UART1_Remappable_Write('1'); -> data is sent to UART 1
UART2_Remappable_Write('2'); -> data is sent to UART 1

UART1_Remappable_Write_Text('UART1'); -> data is sent to UART 2
UART2_Remappable_Write_Text('UART2'); -> data is sent to UART 2

2. UART 1 and 2 can probably set only 9600 bps, another set speed will cause data transfer to fail (UART)

3. program works at 16MHz, at 32MHz program works but character display stops displaying characters, I use LCD library.

Function GetVersion returns string: 7.3.0 RC

Thank you for any advice

Michal

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: Problem with UART and CPU frequency on PIC18F47K42

#2 Post by jovana.medakovic » 25 Nov 2019 12:14

Hello,

Can you zip and send me your project for review?

Kind regards,
Jovana

MicA380
Posts: 4
Joined: 22 Nov 2019 20:05

Re: Problem with UART and CPU frequency on PIC18F47K42

#3 Post by MicA380 » 25 Nov 2019 21:57

Hello Jovana,
I attach the whole project.

Kind regards
Michal
Attachments
MeteoRX_18F47K42 V5.zip
(808.48 KiB) Downloaded 88 times

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: Problem with UART and CPU frequency on PIC18F47K42

#4 Post by jovana.medakovic » 26 Nov 2019 17:04

Hi,

Look at the example which I'm sending you in the attachment.
You need to use the UART_Set_Active function before using the UARTx_Write_Text function.

Could you be more specific regarding the fail values? Which values you need to get, but which you get? Can you send me a screenshot?

Regarding the frequency, I tested our examples from the compiler and it works fine with 32MHz. Can you also try to run this example?
You only need to set a pinout for your LCD.

Kind regards,
Jovana
Attachments
UART.zip
(100.18 KiB) Downloaded 84 times
Lcd.zip
(76.55 KiB) Downloaded 83 times

MicA380
Posts: 4
Joined: 22 Nov 2019 20:05

Re: Problem with UART and CPU frequency on PIC18F47K42

#5 Post by MicA380 » 27 Nov 2019 18:30

Hello Jovana,
the problem with UART is already resolved, adding function UART_Set_Active to my project, everything works,
communication speed can be freely set, tested up to 115kbps.
Program test_LCD works without problems on 32MHz and 64MHz, the problem was in the variable declaration
in my project I had:
Var LCD_RS : sbit at RD2_bit; ...
after repair to:
Var LCD_RS : sbit at LATD2_bit; ....
now works lcd even in my project.


Thank you very much

Kind regards
Michal

Post Reply

Return to “mikroPascal PRO for PIC General”