Hi,
We purchased a 2.8" capacitive touchscreen display, fired it up and ran the test code as per the website no issues. We now want to build BMP images and display them. To do so we ran the ShieldILI9341 sketch but it gives us a lot of compile errors related to the SPI. It seems the SPI registers on the AVR are being accessed from multiple functions but the SFR registers are not visible to those functions. The board is an Arduino Uno WiFi Rev 2. Below is the error dump with most of it removed (it gets repetitive). The start and end are included.
The link we followed is below
https://learn.adafruit.com/adafruit-2-8 ... ng-bitmaps
There seemed to be an alternative link as well that suggested the SdFat library be installed manually but it made no difference (we tried it in hope).
https://learn.adafruit.com/adafruit-gfx ... ing-images
Tried changing the board type to a UNO but different errors came up. Also tried changing register Emulation to ATMEGA328 and None (AVR4809) and neither worked. We're using none for our board.
Arduino IDE version is 1.8.10
Any suggestions are welcome.
Thanks
Ef
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Arduino: 1.8.10 (Windows 10), Board: "Arduino Uno WiFi Rev2, None (ATMEGA4809)"
In file included from C:\Users\ef\Documents\Arduino\libraries\SdFat\src/SdCard/SdSpiCard.h:35:0,
from C:\Users\ef\Documents\Arduino\libraries\SdFat\src/BlockDriver.h:32,
from C:\Users\ef\Documents\Arduino\libraries\SdFat\src/SdFat.h:32,
from C:\Users\ef\Documents\Arduino\libraries\Adafruit_ImageReader_Library\examples\ShieldILI9341\ShieldILI9341.ino:12:
c:\users\ef\documents\arduino\libraries\sdfat\src\spidriver\sdspidriver.h: In member function 'uint8_t SdSpiAltDriver::receive()':
c:\users\ef\documents\arduino\libraries\sdfat\src\spidriver\sdspidriver.h:392:3: error: 'SPDR' was not declared in this scope
SPDR = 0XFF;
^~~~
c:\users\ef\documents\arduino\libraries\sdfat\src\spidriver\sdspidriver.h:392:3: note: suggested alternative: 'SPI'
SPDR = 0XFF;
^~~~
SPI
c:\users\ef\documents\arduino\libraries\sdfat\src\spidriver\sdspidriver.h:393:12: error: 'SPSR' was not declared in this scope
while (!(SPSR & (1 << SPIF))) {}
^~~~
c:\users\ef\documents\arduino\libraries\sdfat\src\spidriver\sdspidriver.h:393:12: note: suggested alternative: 'SPI'
while (!(SPSR & (1 << SPIF))) {}
^~~~
SPI
c:\users\ef\documents\arduino\libraries\sdfat\src\spidriver\sdspidriver.h:393:25: error: 'SPIF' was not declared in this scope
while (!(SPSR & (1 << SPIF))) {}
^~~~
c:\users\ef\documents\arduino\libraries\sdfat\src\spidriver\sdspidriver.h:393:25: note: suggested alternative: 'SPI'
while (!(SPSR & (1 << SPIF))) {}
..
..
..
.. ^
..
Multiple libraries were found for "Adafruit_GFX.h"
Used: C:\Users\ef\Documents\Arduino\libraries\Adafruit_GFX_Library
Multiple libraries were found for "Adafruit_ILI9341.h"
Used: C:\Users\ef\Documents\Arduino\libraries\Adafruit_ILI9341
Multiple libraries were found for "SPI.h"
Used: C:\Users\ef\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.5\libraries\SPI
Multiple libraries were found for "SdFat.h"
Used: C:\Users\ef\Documents\Arduino\libraries\SdFat
Multiple libraries were found for "Adafruit_SPIFlash.h"
Used: C:\Users\ef\Documents\Arduino\libraries\Adafruit_SPIFlash
Multiple libraries were found for "Adafruit_ImageReader.h"
Used: C:\Users\ef\Documents\Arduino\libraries\Adafruit_ImageReader_Library
Multiple libraries were found for "Adafruit_EPD.h"
Used: C:\Users\ef\Documents\Arduino\libraries\Adafruit_EPD
exit status 1
Error compiling for board Arduino Uno WiFi Rev2.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
ILI9341 sketch generates compile errors
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- efmisoyannis
- Posts: 5
- Joined: Sat Feb 01, 2020 8:59 am
ILI9341 sketch generates compile errors
- Attachments
-
[The extension ino has been deactivated and can no longer be displayed.]
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: ILI9341 sketch generates compile errors
Do you have the ZeroDMA library installed?
- efmisoyannis
- Posts: 5
- Joined: Sat Feb 01, 2020 8:59 am
Re: ILI9341 sketch generates compile errors
Hi, No I didn't so I installed it but it made no difference unfortunately. Thanks for responding. Much appreciated.
All ideas welcome
Thanks
All ideas welcome
Thanks
- thorx
- Posts: 4
- Joined: Mon Feb 17, 2020 3:26 pm
Re: ILI9341 sketch generates compile errors
I was just having the same problem: ILI9341 based TFT on top of an Arduino UNO Wifi Rev 2, and the SDFAT driver refuses to compile. Same errors.
The reason for these compilation errors is in the microcontroller: while the common UNO uses an ATmega328P, the Wifi Rev 2 uses a ATmega4809 which is quite a different chip. The SPI registers are different, so any code referring directly to ATmega328P SPI registers won't compile for ATmega4809. I did some googling, saw that more people have encountered the problem, but I couldn't find a quick solution.
I went over the ATmega4809 data sheets and made some changes to the code myself that should solve compilation errors for the ATmega4809. In the file SdSpiDriver.h, go to the lines below (line 372 in my version of the file)
and change this to
This basically replaces the ATmega328P register references with ones for the ATmega4809. I hope this helps you.
Caveat: I'm not an expert of any kind on this low-level microcontroller stuff. This code fix likely works, but there is a chance it is not the fastest possible code for the ATmega4809. However, with the ILI9341 example sketch I do not notice a speed difference between my UNO R3 and my UNO Wifi Rev2, so I am hopeful it is a good fix.
The reason for these compilation errors is in the microcontroller: while the common UNO uses an ATmega328P, the Wifi Rev 2 uses a ATmega4809 which is quite a different chip. The SPI registers are different, so any code referring directly to ATmega328P SPI registers won't compile for ATmega4809. I did some googling, saw that more people have encountered the problem, but I couldn't find a quick solution.
I went over the ATmega4809 data sheets and made some changes to the code myself that should solve compilation errors for the ATmega4809. In the file SdSpiDriver.h, go to the lines below (line 372 in my version of the file)
Code: Select all
//==============================================================================
// Use of in-line for AVR to save flash.
#ifdef __AVR__
//------------------------------------------------------------------------------
Code: Select all
//==============================================================================
// Use of in-line for AVR to save flash.
#ifdef __AVR__
#if defined (__AVR_ATmega4809__)
#define SPDR SPI0_DATA
#define SPSR SPI0_INTFLAGS
#define SPIF 7
#endif // __AVR_ATmega4809__
//------------------------------------------------------------------------------
Caveat: I'm not an expert of any kind on this low-level microcontroller stuff. This code fix likely works, but there is a chance it is not the fastest possible code for the ATmega4809. However, with the ILI9341 example sketch I do not notice a speed difference between my UNO R3 and my UNO Wifi Rev2, so I am hopeful it is a good fix.
- efmisoyannis
- Posts: 5
- Joined: Sat Feb 01, 2020 8:59 am
Re: ILI9341 sketch generates compile errors
Hi Thorx,
sorry I didn't see this until now. Thanks for doing all this work. We'll try it out.
Regards
Ef
sorry I didn't see this until now. Thanks for doing all this work. We'll try it out.
Regards
Ef
- cdno
- Posts: 1
- Joined: Sat May 08, 2021 12:42 am
Re: ILI9341 sketch generates compile errors
I had the same problem now with this example using the adafruit 128x96 oled and an arduino nano every (mega4809)
The example I was following was this https://learn.adafruit.com/adafruit-1-5 ... ng-bitmaps
The changes suggested by thorx above worked nicely! Thanks!
The example I was following was this https://learn.adafruit.com/adafruit-1-5 ... ng-bitmaps
The changes suggested by thorx above worked nicely! Thanks!
Please be positive and constructive with your questions and comments.