MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields

Dear David,

Sorry,

I was in hurry, so not checked image.

Please find the genuine image here,

  1. I checked resister packs, its 5 resistors.
    attached image of lcd back side.

  2. I understand read register sketch is only for UNO shield.

Is there any way to initialize this LCD ?

Please share your valuable suggession.

Thank you.


The 5 resistor packs look like 8-bit write-only interface.

Define USE_SPECIAL and USE_MEGA_8BIT_SHIELD and force begin(0x9488)

Try all the other 320x480 IDs to see which works best.

David.

Dear David,
Thanks for reply.

I am very sorry , I am not reached expertise level to interpret your instructions.
Requesting elaborate little.

I know to force initialize by "begin(0x9488) "

but not clear about defines,
How to define "USE_SPECIAL and USE_MEGA_8BIT_SHIELD" ?

Please support.

I am on a tablet. I suggest that you search this thread for USE_SPECIAL.
I have explained step by step many times.

Yes, it is fiddly. But you chose to buy a non-Uno shield.

David.

Got an 3.97 LCD with ST7793 controller and resolution 400240pix. It seems to have problem with graphictest_kvb scroll function. It moves band of uninitialized memory across the screen. I suspect it is because chip is 432240 and screen only 400*240.

The 7793 can only do Screen Scroll and not Band Scroll.

So yes, you see a white band come into view because the ILI9326, SPFD5420, ST7793, R61509 are 240x432 controllers with a 240x400 Panel.

David.

Hi David.
Can I change the TFT LCD digital pin (LCD_D0 to LCD_D7)?
Maybe to pin 22 to 29.
Because I need the PWM pin for my system output.
How to do that?
Thanks.

Your Uno Shield has fixed wiring. e.g. LCD_D0 is on digital#8. LCD_RD is on Analog#0

If you have a Mega or Due, there are lots of unused pins.
If you have a Uno, you can get PWM on #10, #11 if you are not using the microSD.

You can make an Adapter Shield from a Mega Protoshield. i.e. to receive your Display and route the wiring to pins #22-#29

There has always been a SPECIAL that does exactly this.

Or simply buy a Mega Display Shield in the first place.

David.

Yes David. I use Arduino Due and i will create my own shield.
So, I have to add some code to define the pin.

#define LCD_D2 22
#define LCD_D3 23
#define LCD_D4 24
#define LCD_D5 25
#define LCD_D6 26
#define LCD_D7 27
#define LCD_D0 28
#define LCD_D1 29

Am I write the code correctly?

Thanks alot.
-Alberto RC

Yes, you can verify your wiring with those defines in ithe LCD_ID_readreg sketch.

But it is a very odd choice of wiring. It requires me to write the SPECIAL for you. Life would be simpler if you just copied my existing HOME_MADE_PROTOSHIELD

David.

Dear David,

Thanks for support.

I could configure TFT free fonts with mcufriend_KBV library.
But i can not get (or set) the default small (default little size) font now.

I want to use both Free type font and Default small font.

How set the default font if I set free font in project ?

Rafee

tft.setFont(NULL)

David;

Thanks for your efforts to help support all of the displays out there.

Similar to a recent question about changing the mapping for some of the pins on the mcuFriend shield I need to free up D0 on pin 8 because I need to use the Input control function for the 16 bit timer and this is only on pin 8 for the Uno. Am I correct in that all I need to do is to move the D0 input to the LCD module to Pin 10 (I am not planning on using the SD reader)? Other than the hardware change can this be accomplished by simply declaring in my Sketch:

#define LCD_D0 10

and this will override the value that is in the library?

Also I do not understand what you mean when you say "there has always been a SPECIAL that does exactly this." I am not trying to make work for you but I am a bit new and do not quite understand.

Thanks again for any help.

No, you can not alter the wiring with defines.

The library is designed for Shields. Hence the wiring is fixed.

If you want to hack your shield to make it non-standard, I will post the appropriate SPECIAL.
But seriously, it would be easier to use Timer2.

David.

David;

Thank you for the quick reply.

I have to use the 16 bit timer and therefore I must use pin 8.

Please post a SPECIAL that addresses my modification.

Where would I go to look for your posting of the SPECIAL.

Thank you in advance for your support

Thomas Killam

Yes, I see that ICP1 is on PB0 and this feature is only available on Timer1.

Here is the SPECIAL for mcufriend_special.h:

#define USE_D0_ON_D10
...

//################################ LCD_D0 on D10 ######################################
#elif defined(__AVR_ATmega328P__) && defined(USE_D0_ON_D10)
#warning USE_D0_ON_D10
#define RD_PORT PORTC
#define RD_PIN  0
#define WR_PORT PORTC
#define WR_PIN  1
#define CD_PORT PORTC
#define CD_PIN  2
#define CS_PORT PORTC
#define CS_PIN  3
#define RESET_PORT PORTC
#define RESET_PIN  4

#define BMASK         0x06              //more intuitive style for mixed Ports
#define DMASK         0xFC              //does exactly the same as previous
#define write_8(x)    { PORTB = (PORTB & ~BMASK) | ((x) & (1<<1)) | (((x) & (1<<0)) << 2); PORTD = (PORTD & ~DMASK) | ((x) & DMASK); }
#define read_8()      ( ((PINB & (1<<2)) >> 2) | (PINB & (1<<1)) | (PIND & DMASK) )
#define setWriteDir() { DDRB |=  BMASK; DDRD |=  DMASK; }
#define setReadDir()  { DDRB &= ~BMASK; DDRD &= ~DMASK; }
#define write8(x)     { write_8(x); WR_STROBE; }
#define write16(x)    { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
#define READ_8(dst)   { RD_STROBE; dst = read_8(); RD_IDLE; }
#define READ_16(dst)  { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }

#define PIN_LOW(p, b)        (p) &= ~(1<<(b))
#define PIN_HIGH(p, b)       (p) |= (1<<(b))
#define PIN_OUTPUT(p, b)     *(&p-1) |= (1<<(b))

Untested. #define USE_SPECIAL in mcufriend_shield.h

David.

Edit. Removed the CMASK statements. Added a warning. You should see an orange message when building: #warning USE_D0_ON_D10

David;

Thanks again for the post for the SPECIAL for the mcufriend_kbv library.

I have tried using intuition as to how to utilize the special, unfortunately my attempts are not working.

I do not know what to do to the library or sketch to accommodate the special.

I have tried taking the content you posted and creating a mcufriend_special.h file with the contents and adding the define statement you posted to my sketch. The sketch compiled fine but no changes were seen and the display did not work without pin 8 going to D0.

I am afraid that I have the fix but do not know how to apply the fix. Sorry for not knowing better but I am very new to this platform.

Thanks again for your support.

Thomas Killam

Look at mcufriend_shield.h

You must define USE_SPECIAL for it to even include the mcufriend_special.h

If it finds a suitable SPECIAL, it will use it. Otherwise it just uses the regular shield code.

So you are editing two files.

If you do not understand, buy a pencil and trace through the header files.
Yes, they are enormous. But only a few lines are actually used. i.e. when an #if block is true.

David.

David;

Thanks for your patience.

I do understand what to do and I have made the necessary edits as you suggested to both the mcufriend_special and the mcufriend_shield files in the utility directory for the library.

I turned on the line that invokes the special in the mcufriend_shield file (#define USE_SPECIAL ).

I added the code you sent me to the content of the special file and made sure #define USE_D0_ON_D10 was the only use line not commented out.

Unfortunately I cannot get the compiler to work and I get the following error message. It does not look like you defined the CMASK in the special.

"C:\Users\tkillam\Documents\Arduino\libraries\MCUFRIEND_kbv-master\utility/mcufriend_special.h:944:50: error: 'CMASK' was not declared in this scope
#define setWriteDir() { DDRB |= BMASK; DDRC |= CMASK; DDRD |= DMASK; }

  • ^*
    C:\Users\tkillam\Documents\Arduino\libraries\MCUFRIEND_kbv-master\MCUFRIEND_kbv.cpp:320:9: note: in expansion of macro 'setWriteDir'
  • setWriteDir();*
  • ^*
    exit status 1
    Error compiling for board Arduino/Genuino Uno."
    I think everything else is OK.
    As always thanks for your help and patience.
    Thomas Killam

My apologies. Remove the CMASK statements from setWriteDir and setReadDir.

I will test and edit #1540 later today. I had literally typed the SPECIAL in the Browser which is unwise (tm).

David.