Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

Getting the LCD to work with NIOS II

I know a lot of people have had issues with this, and I've searched through and read many of them, but none of them have helped me. I'll go through my entire process here to make sure I'm not missing something in my setup.

I'm using Quartus 6.0 Web Edition Full and the NIOS II processor and IDE you can download with it. I'm working with Altera's DE2 board with the Cyclone II EP2C35F672C6 fpga.

The LCD is the standard Optrex 16207.

Using the SOPC builder, I've built a custom cpu consisting of the NIOS II/e, a JTAG UART, a UART (RS-232 serial port), an LCD (16207), and the user_logic_SRAM_16Bits_512K that comes on the DE2 board System cd.

After generating the cpu, I:

1) put it on a block diagram

2) added input, output, and bidirectional pins

3) imported a pin assignment table

4) named each pin on the block diagram appropriately based on the pin assignment file

5) compiled the project

Everything compiles fine and the pin assignments show up on the block diagram of the cpu, so I know they were assigned properly.

From the SOPC builder, I open the NIOS II IDE, creating a workspace in my project directory.

Now here is where I'm sort of guessing my way through things. I can add a new hello_world project from their template, which uses the JTAG UART to output "Hello from NIOS II!" When I use this template, the project compiles and works fine with my processor. So at this point, I'm fairly certain my processor works.

/**************************************************************

* THE PROBLEM:

**************************************************************/

I want to write to the LCD. I've tried this many ways, from trying to use code from the HELLO_LED_0 example on the DE2 system cd to trying some code I found on these forums that looked like it might work. I've changed the standard output device on my project to the LCD and tried to write to it using fprintf and a file pointer to the lcd, but that didn't work either.

On a side note, it seems that sometimes the simple "hello_world.c" program does not always run on my processor. Switching between projects in my workspace on the same cpu seems to screw it up every now and then and I can't run the hello world program. I get an error:

Using cable "USB-Blaster [USB-0]", device 1, instance 0x00

Pausing target processor: not responding.

Resetting and trying again: FAILED

Leaving target processor paused

So, to recap: if anyone could look at my process and think they have some code i could use to write to the lcd, I would very much appreciate it. If you see an issue with my process of building the process or creating a software project, let me know. Basically any input anyone has would be appreciated.

Thanks for the time you spent reading this ridiculously long post; I only made it long so I would have to reply 9 times before someone understood what my problem actually was.

-Ben

PS, I don't have a card in the SD card slot.

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    In such cases you shoud follow a standard debu procedure:

    As far as I know (I may be wrong) the LCD SPC builder component is a PIO component with a seral interface driver. So you should:

    1. try to access the PIO registers (read the components source especially headers)

    2. write into the PIO output register (with outputs enabled) and with an oscilloscope (or a LED with a resistor if you do not have a lab) check if pins togle, this way you can be sure that the hardware is OK

    3. now is time to check for software problems, you may place some debugging printf into the driver, so you can verify that the driver is actually used

    4. ...

    IzI
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I think you could make a simple program ,which only control and display some character on the LCD . you must note the timing sequence of LCD.

    Maybe your c program has problems!

    Best Regards!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Try to download the "board Diagnostic" c program and see if the lcd will work.

    if not then check your processor.

    My advice is to use the standard Nios II exmaple.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    hi,

    sounds like there is something wrong with your design:

    <div class='quotetop'>QUOTE </div>

    --- Quote Start ---

    Using cable "USB-Blaster [USB-0]", device 1, instance 0x00

    Pausing target processor: not responding.

    Resetting and trying again: FAILED

    Leaving target processor paused[/b]

    --- Quote End ---

    try using a board example, test it. later you can remove the parts you dont need and try again. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/wink.gif

    regards, martin
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I finally got it working just now. I realized that the FPGA has a pin labeled LCD_ON. Well, when you add the LCD to the NIOS processor, it doesn&#39;t come with that pin, I ended up having to add a one bit PIO output pin that I manually set high in my code (through "IOWR(LCD_ON_BASE, 0, 1);").

    After setting that high, of course, I had to include the usleep(2000); so the LCD test actually completed.

    I don&#39;t understand why their (Altera&#39;s) component doesn&#39;t use the LCD_ON pin.