Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Why SPI LCD not working ?

Status
Not open for further replies.

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
Why SPI Lcd not working. I am using Microchip 8 bit SPI Port expander. The SPI debugger shows that data is sent properly. I am testing it in both Proteus and hardware and it is not working in both. I am using Slaeae Logic Analyzer for testing in hardware. I am using EasyPIC v7 development board.

I am attaching my mikroC PRO PIC project and Proteus file. Proteus file is 8.2 SP2 format. The LCD code is fine because the same code works fine with I2C port expander.

 

Attachments


betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,368
Helped
4,727
Reputation
9,469
Reaction score
4,495
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
122,600
Put the Salae in SPI analysis mode and capture the SPI and LCD control signals as an image so we can see it. Don't worry about the LCD data lines, if the others are correct they will be too. Please label the signals so we can see which they are!

Brian.
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
I removed the hardware setup as I had to test some other project. I will soon setup the hardware again and post the Saleae data. Tell me if there is anything wrong in the values I am writing to the SPI device. I am jsut writing to four registers namely IODIRA, IOCON, GPPUA and OLATA.
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,368
Helped
4,727
Reputation
9,469
Reaction score
4,495
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
122,600
I do not have the MCP23S09 data sheet with me at the moment to check the commands.

All your software has to do is configure the device to output data and write the LCD bits to it in the correct order. You don't need the SDI signal because in that configuration you can't read the LCD status back anyway, in fact you can ground the RW signal so the LCD is always 'reading' the data you send it.

Don't forget in 4-bit mode you have to do two write operations and you need two changes of pin state for each of them, in other words at least 4 bytes have to be sent to the SPI per character you display.

Brian.
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
I made Soft Spi version of MCP23S09 based SPI LCD and it is working fine in Proteus and also hardware but the hardware Spi version is not working. Why ?

In the earlier code I had forgot to call the
Code:
SPI_LCD_Init();
function.



Damn, the SPI LCD is slow compared to I2C LCD.

- - - Updated - - -

It worked. I changed the SPI_Init() function and it worked. In Proteus it is slow.

 

Attachments


betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,368
Helped
4,727
Reputation
9,469
Reaction score
4,495
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
122,600
Well done!
I gave up on MikroC a long time ago and I have never used Proteus. The compiler I use has a built in debugger that runs at much faster speed, it's difficult to say exactly but on my 3GHz i7 machine it simulates at about 'real time' speed when the PIC clock is about 20MHz.

Brian.
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
@Brian

May I know which PIC Compiler you are using ?
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,368
Helped
4,727
Reputation
9,469
Reaction score
4,495
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
122,600
I use "Wiz-C MX" from Forest Electronic Developments. http://www.fored.co.uk/html/wiz_c_mx_-__pic_rapid_developm.HTM

It has a few 'quirks' and the RAD enviromnent can be a little restrictive for some real-time applications but it can be used as a standard ANSI compiler without the RAD and it is excellent for debugging. The 'PIC Key' it refers to is almost identical in function to a PicKit2/3 although not compatible with them, you don't need it to use the compiler or assembler but if you buy one it fully integrates into the debugging environment. It has really useful feature of being able to program and simulate several PICs (even different types) at the same time so you can make them interact in the simulator. For example you could have one as an I2C master and several as I2C slaves not only see how they talk to each other but debug the code in them both simultaneously. Best of all, it's a fraction of the cost of MikroC or it's other competitors.

Brian.
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
Hi Brian

I have Wiz-C MX and also AVIDICY. The problem is I found the IDE too complicated hence I have never used it. If you have a simple LED Blink project for Win-C Mx then please provide it. I will start learning Wiz-C Mx seriously.
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,368
Helped
4,727
Reputation
9,469
Reaction score
4,495
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
122,600
It doesn't get much simpler than the attached file.
Hit Alt+D to arrange the window for debugging, it adapts to your screen size/resolution so yours may not match mine.
Unzip the file then open it with "Project/Restore Archive" and check all the boxes. The folder I used is "c:\projects\MilanRajikFlasher" but you can change it when restoring the archive if you want to.
Click the green "Run Simulation" icon to see it in action. It is configured (see app designer) for simulation with the LED cathode to ground and anode via a resistor to RA0 and for 8MHz clock.

Brian.
 

Attachments

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top