data transmission via UART

General discussion on mikroC PRO for AVR.
Post Reply
Author
Message
serg1980
Posts: 44
Joined: 19 Mar 2014 05:58

data transmission via UART

#1 Post by serg1980 » 18 Oct 2023 11:45

why does an error occur when transmitting data via UART?

Code: Select all

const unsigned int   EOS  = 0xF9F9;
.......
 UART1_Write(Hi(EOS));// Operator '&' is not applicable to these operands 'EOS' Hr_Nd_Blt.c
 UART1_Write(Lo(EOS));// Operator '&' is not applicable to these operands 'EOS' Hr_Nd_Blt.c
at the same time, if you pass the value of a constant to some variable, there is no error

Code: Select all

const unsigned int   EOS  = 0xF9F9;
unsigned int  data;
......
data = EOS;
UART1_Write(Hi(data));// OK
UART1_Write(Lo(data));// OK

serg1980
Posts: 44
Joined: 19 Mar 2014 05:58

Re: data transmission via UART

#2 Post by serg1980 » 18 Oct 2023 12:24

how can I pass a constant via UART???

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

Re: data transmission via UART

#3 Post by IvanJeremic » 20 Oct 2023 13:37

Hi,

You can use const data with functions only if the function strictly says that it uses const data.

Uart_write does not take const data, so you will have to use the solution you used in your seconds code.

Regards,

Ivan.

serg1980
Posts: 44
Joined: 19 Mar 2014 05:58

Re: data transmission via UART

#4 Post by serg1980 » 20 Oct 2023 14:14

IvanJeremic wrote:
20 Oct 2023 13:37
Hi,

You can use const data with functions only if the function strictly says that it uses const data.

Uart_write does not take const data, so you will have to use the solution you used in your seconds code.

Regards,

Ivan.
Thanks for the answer

Post Reply

Return to “mikroC PRO for AVR General”