Announcement

Collapse
No announcement yet.

uLCD32 bus_in

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • uLCD32 bus_in

    Hi,
    I'm trying to read from the 8 bit bus on the uLCD32, but i'm struggling to understand the documentation on this!
    I want to read the 8 bits, and then separate out each bit into a separate variable. However when I read from the bus, I just get a single 0 (even though some of the input lines are high).
    Presumably I'm doing something silly, so If someone could provide a working code example I'd greatly appreciate it.
    I should also point out that the bus is set to the lower 4 bits (0-3) as write bits, and the upper 4 bits (4-7) as read bits.
    Cheers!

  • #2


    Ok could you please try this test

    func main()
    //bus_Set(0xFF); // set all pins to input
    bits bus_Set(0xF0); // set to the lower 4 bits (0-3) as write bits, and the upper 4 bits (4-7) as read bits.
    repeat
    gfx_MoveTo(20,20);
    print(HEX2]bus_In()); // read port bits and display result
    pause(50);
    forever // do it forever
    endfunc
    Regards,
    Dave

    Comment


    • #3


      Yep that now prints "00" which I assume is the hex representation of the byte.
      I'm guessing since it reads 00, that I've stuffed up the wiring to the BUS pins somehow as BUS 5 and 7 should be high.
      Assuming I get it working correctly, Can I separate out the bits into separate variables using the following code?var bus_state := bus_In();var bus4:= bus_state & 0x10 >> 4;var bus5:= bus_state & 0x20 >> 5;var bus6:= bus_state & 0x40 >> 6;var bus7:= bus_state & 0x80 >> 7;

      Comment

      Working...
      X