Lib for ILI9486 - 3.5 inch 480x320 touch TFT for RPi

Working libraries, libraries being ported and related hardware
stevestrong
Posts: 1324
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Lib for ILI9486 - 3.5 inch 480x320 touch TFT for RPi

Post by stevestrong » Fri Jan 13, 2017 9:41 am

Nice.
So, am I wrongly interpreting RM0008 or the datasheets are containing contradictory information?
But if I am not wrong, the 18 MHz limit is valid only for the I2S SPI frequency, not the "general" SPI frequency...

victor_pv
Posts: 1337
Joined: Mon Apr 27, 2015 12:12 pm

Re: Lib for ILI9486 - 3.5 inch 480x320 touch TFT for RPi

Post by victor_pv » Fri Jan 13, 2017 2:28 pm

stevestrong wrote: I am still thinking where should the SPI initialization take place: outside the ILI9486 driver, in setup phase, before or within the driver begin() function?
To make sketches more easily portable between different displays with different driver libraries, I would keep it consistent with the commonly used ones.

User avatar
Squonk42
Posts: 59
Joined: Thu Dec 29, 2016 9:25 am
Location: Bordeaux, France

Re: Lib for ILI9486 - 3.5 inch 480x320 touch TFT for RPi

Post by Squonk42 » Fri Jan 13, 2017 6:09 pm

stevestrong wrote:But if I am not wrong, the 18 MHz limit is valid only for the I2S SPI frequency, not the "general" SPI frequency...
From STM32F103x8, STM32F103xB datasheet, DocID13587 Rev 17 (latest), page 71, section 5.3.16 Communications interfaces:
STM32F103x8 SPI Speed.png
STM32F103x8 SPI Speed.png (163.9 KiB) Viewed 380 times
This is for the general SPI, not only for I2S.

But I agree with Roger, the STM32s are pretty tough on many characteristics, they will withstand a lot more than their specifications.

It is mostly OK to play with these characteristics for a hobby toy, but certainly not count on them for a business project.

stevestrong
Posts: 1324
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Lib for ILI9486 - 3.5 inch 480x320 touch TFT for RPi

Post by stevestrong » Fri Jan 13, 2017 7:24 pm

stevestrong wrote:So, am I wrongly interpreting RM0008 or the datasheets are containing contradictory information?

User avatar
Squonk42
Posts: 59
Joined: Thu Dec 29, 2016 9:25 am
Location: Bordeaux, France

Re: Lib for ILI9486 - 3.5 inch 480x320 touch TFT for RPi

Post by Squonk42 » Fri Jan 13, 2017 8:41 pm

stevestrong wrote:
stevestrong wrote:So, am I wrongly interpreting RM0008 or the datasheets are containing contradictory information?
The situation is a little bit more complex than that: in the STM32F103x8/B, there are actually 2x SPI peripherals, SPI1 and SPI2. SPI1 runs on the APB2 bus with fpclk max = 72 MHz, and SPI2 runs on the APB1 bus with fpclk max = 36 MHz, so we may interpret this as SPI1 can go up to 36 MHz, whereas the SPI2 only reaches 18 MHz.

However, for all MCUs I have used so far, the datasheet is always more specific than the reference manual which covers a whole family of devices, and characteristics always supersedes values given in feature lists.

So no, you are not interpreting the RM wrongly, but you should believe the datasheet over it, and characteristics over feature lists, and there is also a discrepancy between the two documents at the same time ;)

BTW, which SPI peripheral are you using?

stevestrong
Posts: 1324
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Lib for ILI9486 - 3.5 inch 480x320 touch TFT for RPi

Post by stevestrong » Fri Jan 13, 2017 8:53 pm

For this project i use SPI 1. But i have projects in which both SPI 1 and 2 are working simultaneously, with DMA.

palmerr
Posts: 58
Joined: Tue Jan 31, 2017 6:21 am
Location: Melbourne, Australia

Re: Lib for ILI9486 - 3.5 inch 480x320 touch TFT for RPi

Post by palmerr » Tue Jan 31, 2017 7:07 am

Simon,

I've been working on a similar project on a Teensy platform, saw your code and thought I'd try it out on an STM32. The board (a Maple Mini clone) arrived yesterday, so I fired it up following Roger's instructions on the Wiki and YouTube (very useful). No problems with LED blink, etc, so I think I have the tool-chain sorted for the STM.

Compiling the code from github produces some errors (not a problem), but one of them is the following - which is an apparent mismatch with SPI.cpp in hardware\Arduino_STM32\STM32F1\libraries\SPI\src.

Your code, below, seems to be writing a single value multiple times. This makes sense for drawing lines, etc of a single colour, but doesn't match with the SPI write() function call.

The two-argument SPI write() function expects the first argument of be a pointer to an array of items to be written, not just a single item. (void SPIClass::write(const uint8 *data, uint32 length).

Can you give me any clues about where I might have gone wrong, or if you have made any improvements since you uploaded these files to github?

I'll continue to debug while awaiting a response, as it's more than likely the problem is between my chair and keyboard!

Richard
-------------------
Adafruit_ILI9486_STM32.cpp

void writedata16(uint16_t color, uint32_t num)
{
SPI.setDataSize(DATA_SIZE_16BIT);
CD_DATA;
CS_ACTIVE;
//#ifdef USE_DMA
if (useDMA) {
lineBuffer[0] = color;
while (num>0xFFFF) {
SPI.dmaSend(lineBuffer, 0xFFFF, 0);
num -= 0xFFFF;
}
SPI.dmaSend(lineBuffer, num, 0);
//#else
} else {
SPI.write(color, num);
//#endif
}
CS_IDLE;
SPI.setDataSize(DATA_SIZE_8BIT);
}
-------------------------------
SPI.cpp

void writedata16(uint16_t color, uint32_t num)
{
SPI.setDataSize(DATA_SIZE_16BIT);
CD_DATA;
CS_ACTIVE;
//#ifdef USE_DMA
if (useDMA) {
lineBuffer[0] = color;
while (num>0xFFFF) {
SPI.dmaSend(lineBuffer, 0xFFFF, 0);
num -= 0xFFFF;
}
SPI.dmaSend(lineBuffer, num, 0);
//#else
} else {
SPI.write(color, num);
//#endif
}
CS_IDLE;
SPI.setDataSize(DATA_SIZE_8BIT);
}

stevestrong
Posts: 1324
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Lib for ILI9486 - 3.5 inch 480x320 touch TFT for RPi

Post by stevestrong » Tue Jan 31, 2017 8:19 am

Sorry, but I cannot see any mismatch. My latest commit was a month ago, and it should work.
If you have problems, please post the compiler generated error.
It seems that you pasted wrong info for the second function.
Extract from SPI.h:

Code: Select all

    /**
     * @brief Transmit one byte/word a specified number of times.
     * @param data to transmit.
     */
void write(uint16 data, uint32 n);	
	
    /**
     * @brief Transmit multiple bytes/words.
     * @param buffer Bytes/words to transmit.
     * @param length Number of bytes/words in buffer to transmit.
     */
void write(const void * buffer, uint32 length);
So there are two different functions, the first with 16 bit (color) value, the second with a pointer to a buffer of 8 or 16 bit (color) values as first parameter.

victor_pv
Posts: 1337
Joined: Mon Apr 27, 2015 12:12 pm

Re: Lib for ILI9486 - 3.5 inch 480x320 touch TFT for RPi

Post by victor_pv » Tue Jan 31, 2017 5:33 pm

stevestrong wrote:Sorry, but I cannot see any mismatch. My latest commit was a month ago, and it should work.
If you have problems, please post the compiler generated error.
It seems that you pasted wrong info for the second function.
Extract from SPI.h:

Code: Select all

    /**
     * @brief Transmit one byte/word a specified number of times.
     * @param data to transmit.
     */
void write(uint16 data, uint32 n);	
	
    /**
     * @brief Transmit multiple bytes/words.
     * @param buffer Bytes/words to transmit.
     * @param length Number of bytes/words in buffer to transmit.
     */
void write(const void * buffer, uint32 length);
So there are two different functions, the first with 16 bit (color) value, the second with a pointer to a buffer of 8 or 16 bit (color) values as first parameter.
Steve, did you add this one to the core?

Code: Select all

void write(uint16 data, uint32 n); 

stevestrong
Posts: 1324
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Lib for ILI9486 - 3.5 inch 480x320 touch TFT for RPi

Post by stevestrong » Tue Jan 31, 2017 10:09 pm

There is a PR pending which contains this.
This is one of the functions which makes the DMA almost obsolete as there is no spi clock gaps between consecutive data, all continuous, for 16 bit data at least.
Last edited by stevestrong on Tue Jan 31, 2017 10:14 pm, edited 1 time in total.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests