I/O Confusion

I’m trying to attach an LCD (HD44780) to the aux Data Bus and I’m not having much luck. This is the first time I’ve ever written code from scratch on the RCM3000. I’ve always maintain existing code so I have learn a bit…

I have EN tied to I6 and PG4 tied to R/S.

I can’t see I6 change at all (but I can see the data in the bus)

I must have messed up in the software somewhere.

WrPortI(PEDDR, &PEDDRShadow, 0xFF);		//set bits 7,6,5,4,3,2,1,0 to output
   WrPortI(PEFR, &PEFRShadow, 0xFF);									// Set all of Port E to Strobes
   WrPortI(PEDR, &PEDRShadow, 0xFF);
    WrPortI(IB6CR, &IB6CRShadow, 0x68);					// I6 is clk strobe active high

I have a scope on I6 I’m expecting to see it toggling since I put a loop around the init process, but I see 3.36V always.

Can anyone see my error?

Figured out my problem, it was hardware related.

Thanks for the help, I did get my LCD working.

I had the address set like that for a test and I forgot to set them back. Since I don’t use the address bus it doesn’t matter.

Why does it take sooooo long to have a post displayed on this board now?


I just got an HD44780 working with my RCM5700 via AUX_IO. Though there are some port differences from the RCM3000, perhaps these code fragments will help. I used external port 0x8001 with PE4 specified as the I/O strobe. PE4 is not brought out to the connector on the RCM5700 so I used IOWR for the actual strobe to my 74HCT273 latch. My HD44780 is using 8-bit data mode.

The first line – #define PORTA_AUX_IO – is required on the RCM5700 and on all Rabbit boards, I think, for setting up the AUX_IO routines. The other initialization statements in main() are also required to set up the Rabbit hardware.

Note that I used this in a COSTATE, so I had to use COFUNC and WFD and WAITFOR statements. It complied with DC_10.44.

One thing I noticed in your code is that you used mutliple port addresses (0xC000-0xC006). They should probably all be to the same port, wherever your HD44780 is connected.

Good luck!

#define PORTA_AUX_IO // required to enable auxiliary I/O bus

#define LCD_EN       1           // Register Select    port B bit 1
#define LCD_RS       2           // Read/Write signal  port D bit 2
#define LCD_RW       3           // Enable signal      port D bit 3

#define Cmd       0           // LCD Command mode
#define Data      1           // LCD Data mode

#define Lcd_Clear          0x01
#define Lcd_solidCursor_On 0x0E
#define Lcd_noCursor_On    0x0C
#define Lcd_blinkCursor_On 0x0F
#define Lcd_Cursor_Home    0x03
#define Lcd_Off            0x08

cofunc void LcdWrite(int mode, char hex);

cofunc void LcdWrite(int mode, char hex) {

  BitWrPortI(PDDR, &PDDRShadow, mode, LCD_RS);  // Set LCD cmd/data mode
  BitWrPortI(PDDR, &PDDRShadow, 0, LCD_RW);  // Set LCD write mode

  WrPortE(0x8001, NULL, hex);                // write LCD command to 0x8001

  BitWrPortI(PBDR, &PBDRShadow, 1, LCD_EN);  // Start sending data
  waitfor(DelayMs(1));                       // Wait 1 ms for LCD to read
  BitWrPortI(PBDR, &PBDRShadow, 0, LCD_EN);  // Finish transmission
  waitfor(DelayMs(1));                       // Wait 1 ms until next write


   // SlavePortControlregister
        WrPortI(SPCR, &SPCRShadow, 0x8C);  // Enables AUX I/O

   // I/O Bank Control Reg to use 0x8000
        WrPortI(IB4CR,&IB4CRShadow, 0x6A); // 7 ws /iowr active low

   // Initialize LCD controls to output
        BitWrPortI(PBDDR, &PBDDRShadow, 1, LCD_EN); // port B
        BitWrPortI(PDDDR, &PDDDRShadow, 1, LCD_RS);
        BitWrPortI(PDDDR, &PDDDRShadow, 1, LCD_RW);

   // Set output bits off
        BitWrPortI(PBDR, &PBDRShadow,  0, LCD_EN); // port B
        BitWrPortI(PDDR, &PDDRShadow,  0, LCD_RS);
        BitWrPortI(PDDR, &PDDRShadow,  0, LCD_RW);

   // Make sure PD0-PD4 not set to alternate function
    // BitWrPortI(PBFR,  &PBFRShadow,  0, 1);  // no FR for port B
        BitWrPortI(PDFR,  &PDFRShadow,  0, 0);
        BitWrPortI(PDFR,  &PDFRShadow,  0, 1);
        BitWrPortI(PDFR,  &PDFRShadow,  0, 2);
        BitWrPortI(PDFR,  &PDFRShadow,  0, 3);

   costate	// this task updates the LCD panel every 1 second

         // initialize the LCD panel

         wfd LcdWrite(Cmd, 0x30);         // Send reset
         wfd LcdWrite(Cmd, 0x30);         // Send reset
         wfd LcdWrite(Cmd, 0x30);         // Send reset
         wfd LcdWrite(Cmd, 0x38);         // Send cmd 8bit, 2 lines, 5x7 font
         wfd LcdWrite(Cmd, 0x08);         // Turn display off
         wfd LcdWrite(Cmd, 0x0C);         // Turn display on
         wfd LcdWrite(Cmd, 0x06);         // Set Entry mode, increment move
         wfd LcdWrite(Cmd, 0x10);         // Display and cursor shift
         wfd LcdWrite(Cmd, 0x0E);         // Switch display and cursor on
         wfd LcdWrite(Cmd, 0x01);         // Clear the LCD and jump to zero
         wfd LcdWrite(Cmd, 0x03);         // Jump cursor to zero and clear any shift

Hi Ron,

The reason your posts were taking so long is we recently changed to a moderation of new users. On the changeover, some existing users were put into the new user group as well. This was typically users who had suspicious names like ‘newviagra’ or users who had not posted, but shared certain subnet addresses with repeated SPAM producing addresses. How your registration ended up marked as a new user, I don’t know. I guess the search tool that was used to change some of the existing user registrations has some problems. I have changed your account back to registered user and you should no longer see the delay in posting.