 |
 |
View previous topic :: View next topic |
Author |
Message |
donmezbilek
Joined: 06 Jan 2024 Posts: 5
|
Screen writing with graphic LCD |
Posted: Wed Jun 11, 2025 3:17 am |
|
|
I'm working on a project with the PIC18F46K42 to display text on a graphic LCD. In the library, it says to connect the data bus pins (DB0 to DB7) to port D, but I connected them differently. How can I modify the library to match my custom pin connections? Can you help me with this?
DB0 (A3)
DB1 (E1)
DB2 (E2)
DB3 (C0)
DB4 (C1)
DB5 (C2)
DB6 (D0)
DB7 (D1)
CS1 (D3)
CS2 (D2)
RST (C5)
R/W (C6)
D/I (C7)
E (D7)
[snip]
//// (C) Copyright 1996, 2004 Custom Computer Services ////
//// This source code may only be used by licensed users of the CCS ////
//// C compiler. This source code may only be distributed to other ////
//// licensed users of the CCS C compiler. No other use, ////
//// reproduction or distribution is permitted without written ////
//// permission. Derivative programs created using this software ////
//// in object code form are not restricted in any way. ////
/////////////////////////////////////////////////////////////////////////
Don't post CCS driver code in future please.[/u] |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9478 Location: Greensville,Ontario
|
|
Posted: Wed Jun 11, 2025 5:24 am |
|
|
1st you've posted CCS driver code which is not allowed.it's one of the rules....
2nd WHY did you change the connections ! The easy solution is to configure the PIC/LCD as CCS driver says.
3rd If you can't ,one possible solution requires YOU to to locate ...
this line of code
output_d(data); // Put the data on the port ....
and then create code that takes the 'data' byte and puts each bit onto whatever I/O pin you chose. IE data bit 0 goes to I/O portA.3.
this 'may' work, though it will be slower.
I don't have that PIC, use the GLCD but in my mind it can work.
Others may reply sometime later..... |
|
 |
jeremiah
Joined: 20 Jul 2010 Posts: 1392
|
|
Posted: Wed Jun 11, 2025 8:31 am |
|
|
You'll need to remove that driver code from your post. It violates your license agreement with CCS so there could be legal ramifications.
If it helps, everyone here will have their example and driver code, so it is ok just to mention the name of your driver and the CCS compiler version and we can locate the code without violating the license.
As for things you can do. Not using a single port for your data bus is going to make your code run significantly slower. This may or many not be a problem depending on your application needs.
I would replace all calls to output_d() with a call to a function similar to this:
Code: |
void set_output(unsigned int8 value){
output_bit(PIN_D1, bit_test(value, 7)); // DB7
output_bit(PIN_D0, bit_test(value, 6));
output_bit(PIN_C2, bit_test(value, 5));
output_bit(PIN_C1, bit_test(value, 4));
output_bit(PIN_C0, bit_test(value, 3));
output_bit(PIN_E2, bit_test(value, 2));
output_bit(PIN_E1, bit_test(value, 1));
output_bit(PIN_E0, bit_test(value, 0)); // DB0
}
|
That'll individually set each line based on the value you would have originally given to output_d(). It will be much much slower as it changes from the driver's original single register write to 8 individual bit tests and sets. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19854
|
|
Posted: Thu Jun 12, 2025 2:04 am |
|
|
Others have made the point, but let's expand a little.
On your PIC, you have port A, B, C & D all offering 8 bits/ The graphic
write operations are fundamental to the speed of the display. You do thousands
of writes any time a major update of the display is done, and a small amount of of extra delay here will massively slow the code down.
CCS therefore put the 8 data bits directly onto a single port. It is fairly easy
to rewrite to use a different port if this is easier to wire, but splitting the byte
onto multiple pins, will slow the library by a factor of tens of times. .
Jeremiah's approach shows how this can be done, and there are some ways
this can be improved in speed a little, but any approach is going to make
the display basically unacceptable.
You need I'm afraid to rethink your hardware. The put it all on one port
approach is the only one that will genuinely give acceptable performance. |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9478 Location: Greensville,Ontario
|
|
Posted: Thu Jun 12, 2025 5:15 am |
|
|
curious, I cut code and saw that simple 'output to a port' is 3 instructions. The set_output() creates 49 lines of code( 6 per test x 8 +1 ). So on average I'd assume that would take at least 16X longer to execute.
As Mr. T points out best to reconfigure your PIC to use a 'port' and not 8 I/O pins. |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|