Greetings,

I'm working on mcp9800 library this morning, and I've run into
something that is confusing to me. I've looked at the JALV2 manual and
narrowed the issue down to a short example.  I don't know whether I'm
just confused (likely), or possibly have run into a compiler problem?

In the example below, it seemed to me that I should use the 'cast to
word' to make the code more readable and my intentions clear (the
library returns a byte but I need a word instead). But when I do, the
value returned from the i2c library is ignored, and instead, variable
'b' is explicitly set to zero.  If I remove the 'cast to word' the
program runs correctly and no warning is given by the compiler.

I'd appreciate any insights.

Thank you,

William

    include 18f2680
    pragma target clock 20_000_000
    pragma target OSC  HS
    pragma target XINST disabled
    pragma target WDT  disabled
    pragma target LVP  disabled
    pragma target MCLR external

    const word _i2c_bus_speed = 1
    const bit _i2c_level = true
    include i2c_hardware

    var word a
    var word b
    var byte c

    forever loop
       a = word( i2c_receive_byte(true) )
       b = a
       c = byte(b & 0xff)
       portB = c
    end loop


-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to