BusInOut Qurstion

22 Jan 2011

here is a snippet of the code I am trying to port to drive a display controller (SSD1963)

. .

BusInOut DB(p12,p11,p10,p9,p8,p7,p6,p5); /* databus D0-D7 */

void Write_Command(unsigned char command){ nRD = 1;

DB = command; write(DB); RS = 0; nWR = 0; CS = 0; wait_us(2); CS = 1; nWR = 1;

My problem:

where I have write(DB), what I am trying to do is to write a data bayte out to my bus. Originally I assumed just writing DB=command would do it, or write(DB), but clearly this is not the case. I could not find a code example on the site. I've tried write.DB but I contine to get an error message indicating that write is not recognized. Any pointers? thanks

22 Jan 2011

Looks like its not possible to edit post titles. That should read BusInOut Question!

22 Jan 2011

Actually, DB=command; should work. However, you should first need to set it to output mode, since it's a dual mode object.

DB.output();
DB = command; // or DB.write(command);
....
DB.input();
result = DB; // or result = DB.read();

P.S. for examples for the standard classes you should check the Handbook.

22 Jan 2011

Thanks Igor - I'll take a look in the morning. Its quite late(early) here in Tokyo.

23 Jan 2011

I made the changes you proposed, and the code compiles ok. I still have problems with this. However, when I look at the bus pins with a scope, nothing is going on.

Do I need to explicitly declare each bus pin as a DigitalInOut before I declare a bus?

Also, in

BusInOut DB(p5,p6,p7,p8,p9,p10,p11,p12); /* databus D0-D7 */

I assume the compiler automatically assumes p5 is bit 0 and p12 is bit 7. Here is the code

http://mbed.org/users/andrewcrussell/programs/Display_Driver/llg44p

Thanks

23 Jan 2011

Andrew R wrote:

I made the changes you proposed, and the code compiles ok. I still have problems with this. However, when I look at the bus pins with a scope, nothing is going on.

In you code you mention below I cannot see any call to DB.output(), which means your bus is set as input.

Andrew R wrote:

Do I need to explicitly declare each bus pin as a DigitalInOut before I declare a bus?

No.

24 Jan 2011

Hendrik, thanks for that input. I'll need to wade through this and try to sort it out.

24 Jan 2011

Hello Hendrik, do you mean this code?

I thought DB.write(command)would have done it as shown below

void Write_Command(unsigned char command) { nRD = 1; /* make sure the RD is HIGH just to be sure */ DC=1; select comand mode nWR = 0; set write active low to SSD1963 CS=0; select SSD1963 wait_us(1); slow things down a bit - will be removed in final version DB=command; transfer 'command' data do DB DB.write(command); write it out to the bus lines wait_us(1); as above nWR = 1; latch the data into the SSD1963 CS = 1; de-slect the SSD1963 - finished }

24 Jan 2011

I don't think DB.write will set the port to output automatically. Since you seem to do writes only, why don't you use BusOut for a start?

20 Feb 2011

Hello, I'm back again after a short hiatus.

I am still not able to write data or commands to my display. I've checked the control signals and they appear to be working correctly. I just want to confirm that I am using the BusInOut function correctly as shown in the code snippet below:-

void Write_Command(unsigned char command) { nRD = 1; /* make sure the RD is HIGH just to be sure */ DC=1; nWR = 0; CS=0; wait_us(1); DB.output(); DB=command; wait_us(1); CS = 1; nWR = 1; }

Thanks

20 Feb 2011

BTW, this is how I set the Bus up:-

BusInOut DB(p5,p6,p7,p8,p9,p10,p11,p12); /* databus D0-D7 */

and the lines are toggling when I look with a scope

thanks

20 Feb 2011

. . . finally, finally, its working!