Compiler warning

0 views
Skip to first unread message

David VB

unread,
Nov 26, 2025, 10:57:04 AM (2 days ago) Nov 26
to jallist
Hi there,

When trying to compile the following line:
I2CADRESS = 0b101 | (ADR1 << 1) | (ADR2 << 2) | (ADR3 << 3) | (ADR4 << 4)

the compiler gives me the following warnigs (but seems able to continue to compile)
"Warning Value out of range [5:0...1]"

I understand this as "The value of bit 5 is not between 0 and 1"

I2CADRESS is defined as byte
ADR1..ADR4 are aliases on input pins (on which DIP-SWITCHES are connected to choose the adress)  Ex: alias ADR1 is pin_c7
I am using a PIC16F1768 for this project.

Any idea how to avoid that warning ?   

Rob CJ

unread,
Nov 26, 2025, 12:54:44 PM (2 days ago) Nov 26
to jallist
Hi David,

If ADRx is a bit should you not convert it first to a byte and then shift, so like this:

I2CADRESS = 0b101 | (byte(ADR1) << 1) | (byte(ADR2) << 2) | (byte(ADR3) << 3) | (byte(ADR4) << 4)

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens David VB <pinhe...@gmail.com>
Verzonden: woensdag 26 november 2025 16:57
Aan: jallist <jal...@googlegroups.com>
Onderwerp: [jallist] Compiler warning
 
--
You received this message because you are subscribed to the Google Groups "jallist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallist+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/jallist/f6aacc83-31ed-4011-8c16-f3f15b67ef10n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages