Jump to content

I2C connection to MatrixOrbital LCD


argtrak
 Share

Recommended Posts

Hi,

I'm new here, I just finished building my CORE and SID module   ;D   Both work gooood :)  still need a control surface, (working on that).

My question:  I have an LCD here made by Matrix Orbital (LK20425) that already has a RS232/I2C interface built on it, and I was wondering if it would be possible to make a custom LCD drive that would use the bankstick port to reach the LCD's I2C address that is in the 0x50-0x6E range...  (bankstick if I remember well seems to be I2C compatible)

Any hints, clues, sample code?! ;) would be appreciated.

Thanks.

Link to comment
Share on other sites

Hi Pascal,

good idea! I will open the IIC interface functions for the users with the next MIOS release so that the integration into app_lcd.inc should be a piece of cake :)

Although I'm not able to try it out by myself, I don't expect problems.

Best Regards, Thorsten.

Link to comment
Share on other sites

Hi TK,

You're making my day here!  8)  And about the testing, just let me know one way or another, and I'll gladly do some testing for you!

About the next release of MIOS, any approximate date in mind?  I'm just curious...

Thanks a lot, :)

Pascal

Link to comment
Share on other sites

It could take some days, however, I just have extended the mios_vectors.inc table by the already available IIC functions and I wrote a small example based on the Matrix Orbital specs (which are hopefully correct)

First upload this interim MIOS release: http://www.ucapps.de/tmp/mios_v1_3b.syx.zip

Thereafter the IIC example: http://www.ucapps.de/mios/custom_lcd_iic_v1.zip

If it doesn't work with your display, you possibly have to change the control codes (or just the device address) in app_lcd.inc

If this app is running (you should see a "Hello World" on the screen), you can add the driver to existing applications by copying "mios_vectors.inc" and "app_lcd.inc" into the appr. directory and by reassembling the code. You also have to add the MIOS_LCD_TypeSet function to the init code, alternatively you could burn the bootloader again with an adapted ID field.

Btw.: The IIC functions could also be used to communicate with other PICs or peripheral chips - Remark: MIOS itself doesn't support the IIC slave functions since the appr. pins are allocated

Best Regards, Thorsten.

Link to comment
Share on other sites

TK,

I'm testing it out, and I end up getting something on screen, but it's all parenthesis...   )))))))))))))))))   it seems every characters get sent as ) instead of the actual character...  any clue why that would be?

It's almost like MIOS_IIC_ByteSend would reinitialize the byte to send before sending it.

Gotta leave to work, it's 7:30am here...

Pascal

UPDATE:  I changed the address in app_lcd.inc, and the address on the device itself to something different and the characters on the screen are a different character, (they look like weird u on the side)  It looks like the bytes received by the LCD have something to do with the address???  I'm a bit puzzled...

any clue?

Pascal

Link to comment
Share on other sites

Hi Pascal,

yes, I've a clue :)

I've implemented an IIC slave with the PIC16F877 today (*) in order to test the master function and noticed that the clock stretching feature of the IIC bus is more important than expected - a temporary version is now available here:

http://www.ucapps.de/tmp/mios_v1_3b2.syx.zip

The clock stretching routine doesn't come with a timeout mechanism yet, this means: if the slave doesn't react or if you unplug an IIC device, MIOS could reboot after 2 seconds. This will be fixed in the final version.

The final version will also allow to disable the clock stretching for fastest transfer to the BankStick.

Important: w/ the clock stretching function you have to add a 1k pull-up resistor to the SCL line!

(*) some words to the PIC16F slave: Richard suggested the support of IIC a while ago in order to allow a simple adaption of hardware extensions. I plan to publish the PIC16F based IIC/MIDI skeleton under GPL to give you the basics. The DMX extension could be realized in this way - the example already provides a buffered MIDI In/Out accessible via the IIC bus.

In other words: the example can be used as MIDI IO extension for MIOS, more than 100 MIDI IO ports could be controlled from a single MIOS core ;-)

Best Regards, Thorsten.

Link to comment
Share on other sites

Hi Thorsten,

Tried the 1.2b version, with and without the 1k resistor, and the results stayed the same...  I found out something else though.  Kind of puzzling, but you can probably make sense out of it.

USER_LCD_init  seems to work fine, it adjusts the contrast and I can turn on or off the backlight.  I found that strange since I couldn't see any understandable text displayed on the LCD (hello world message...) so I went out in the app_display.inc file, in the USER_DISPLAY_Tick function and I put some code that would send characters to the screen and it works so my IIC connection seems to be working okay.

Here's the code.

IRQ_DISABLE

call      MIOS_IIC_Start

movlw      USER_LCD_IIC_DEVICE_ADDRESS

call      MIOS_IIC_ByteSend

movlw      65            ; A

call      MIOS_IIC_ByteSend

movlw      66            ; B

call      MIOS_IIC_ByteSend

movlw      67            ; C

call      MIOS_IIC_ByteSend

call      MIOS_IIC_Stop

IRQ_ENABLE

of course, being in the tick function, the text is sent over and over, and wraps around the screen, but it displays okay.

I tried to put a call to MIOS_LCD_PrintHex2 in the same function:

movlw      66            ; 'B'

call      MIOS_LCD_PrintHex2

That doesn't work. (gives me the same weird u on its side)

Can you deduce anything with this information?

Best regards, Pascal

Link to comment
Share on other sites

Hi Pascal,

ok, I guess that I've also found the reason for this problem: MIOS_GLCD_TMP1 is used by the IIC driver as temporary counter and it is also used by app_lcd.inc as temporary buffer. Means: the counter function overwrites the buffer.

Shit happens - never use registers w/ different routines... :-/

Workaround: replace USER_LCD_PrintChar by following function:

USER_LCD_PrintChar
      ;; temporary save character in MIOS_GLCD_TMP3
      SET_BSR      MIOS_GLCD_TMP3
      movwf      MIOS_GLCD_TMP3, BANKED

      IRQ_DISABLE                        ; interrupts have to be disabled during IIC transfer
      call      MIOS_IIC_Start                  ; start IIC
      movlw      USER_LCD_IIC_DEVICE_ADDRESS      ; send device address
      call      MIOS_IIC_ByteSend
      SET_BSR      MIOS_GLCD_TMP3
      movf      MIOS_GLCD_TMP3, W, BANKED      ; send character
      call      MIOS_IIC_ByteSend
      call      MIOS_IIC_Stop                  ; stop IIC
      IRQ_ENABLE                        ; enable interrupts
      return

Link to comment
Share on other sites

Hi Thorsten,

The update works good, the demo application says "Hello World!" :)

I have yet one more problem/question...  I put the modified app_lcd.inc in the sid_v1.5b_18f_stepC project, it compiles without any problem.   But I can't seem to be able to convert the hex to sysex.  Is the application too big to contain a custom IIC LCD driver? I keep getting errors of this type:

[tt]...

Block 007800-007BFF allocated - Checksum: 4E

ERROR: you are trying to overwrite the OS address range

Use the -os_upload flag if this was your intention![/tt]

I tried to rem almost all the stuff in the LCD driver and it converts, but as soon as I unrem more than 2 or 3 mov instructions, it gives me that error message.  I tried deactivating the control surface of the SID firmware and that gave me enough space to leave unremmed all of the LCD driver code but that's kind of going backwards if you see what I mean.  I'm kind of stuck. :'(

Pascal

Link to comment
Share on other sites

Great! :)

Regarding the SID application: it's out of memory, you have to remove the CC strings under CS_MENU_CC_TABLE (file: cs_menu_cc_table.inc) in order to free 2k of memory

Simplest solution: write "#if 0" below the label and "#endif" at the end of the file

Best Regards, Thorsten.

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...