Should I use Arduino or ASF4...

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I know I'm setting myself up for an onslaught of opinions, but here's the scoop:

 

My client's project requires a SAMD21 with an SD card + FATFS driving a rather large color LCD touch screen.  I'm trying to decide if I should write the whole thing using the Arduino framework or using Atmel START / ASF4.

 

On one hand, I'm very comfortable with the Atmel START / ASF4 environment.  On the other hand, the touch screen vendor has provided an Arduino-based driver with example code.  This is a big help because it's essentially the only legible documentation for the device.

 

To go the ASF4 route, I'd have to:

* port the touch screen drivers from Arduino to ASF4

* find or write the SD Card / FATFS system for the SAMD21 (I am surprised that Atmel START doesn't support it)

 

To go the Arduino route, I'd have to:

* find or write the SD Card / FATFS system for Arduino (I suspect that already exists?)

 

At the end of the day, I'm agnostic: I just want a robust and maintainable body of code. 

 

So (I say as I don my asbestos flame-resistant suit), which approach would you recommend, and why?

 

Last Edited: Fri. Nov 5, 2021 - 05:21 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am pretty confident that ASF4 or Start will support FATFS.

And it probably supports popular TFT displays like ILI9341

 

So you should stick with what you know.

But first post a link to the actual colour display hardware.

 

The Arduino route will have library code for everything.

But you will need to gain familiarity with Arduino first.   e.g. build library examples.  then write simple sketches of your own., ...

 

Post links to your screen.   This will determine ASF4 support or which Arduino library.

 

I can help you with Arduino code.   If ASF4 does not support your hardware I am not brave enough to decipher ASF4.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rdpoor wrote:
I'm very comfortable with the Atmel START / ASF4 environment.

should we infer that you're not comfortable/familiar with Arduino ?

 

I have never used the Arduino IDE or Framework, but have "stolen" Arduino stuff before

 

find or write the SD Card / FATFS system for the SAMD21 (I am surprised that Atmel START doesn't support it)

Surely FatFs is just source code - so there's not really any "support" needed in START / ASF ?

 

All you need to do is provide the SPI driver - which you could do using START / ASF support, or "bare metal".

 

port the touch screen drivers from Arduino to ASF4

"Arduino" is just C++

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

should we infer that you're not comfortable/familiar with Arduino ?

Let's just say it took me a good while to figure out that "Arduino Pin 10" maps to GPIO PB14 on the SAMD21 Xplained Pro board.  Etc.

All you need to do is provide the SPI driver - which you could do using START / ASF support

I was under the impression that the board package for the SAMD21 XPRO DOES provide at least one SPI object -- I'm still figuring out how each SERCOM maps to different Arduino SPIn instances. 

 

And I'd be gobsmacked if there's not already good FATFS support in Arduino -- I just need to learn how to find the proper libraries and link them to the underlying SPI object.

 

But I'll get there.  Thanks.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please just say what type of colour screen you have.   Preferably with a link.   e.g. Ebay sale page.

 

Then we could offer sensible advice.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@david.prentice: Pardon!  I wasn't trying to be cagey.  Here's the link:

 

   https://www.buydisplay.com/low-c...

 

As  mentioned, the vendor already provides a comprehensive Arduino-based library and sample code for the display, and I already have the test pattern code up and running:

 

    https://www.buydisplay.com/ardui...

 

Due to external reasons, I'm now mostly committed to going the Arduino route, so another important data point would also be the Arduino board package I'm using for the SAMD21:

 

    https://github.com/AtmelUniversi...

 

(If there is a better approach, please let me know sooner than later!)

 

I have a bit of a learning curve in figuring out how to integrate an SD card with FATFS into an Arduino project.  For example: I'll need at least two SPI interfaces -- one for the display, one for the SD card -- and one I2C interface for the touch interface.  I know how to allocate and initialize SAMD21 SERCOMs in ASF4, I'm less certain how to allocate multiple SERCOMs in the Arduino world.

 

 

- rdp

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@david.prentice (and anyone else):

 

Here's a concrete question that's probably easy to answer by anyone who knows the Arduino ecosystem:

 

The Arduino SD library (https://www.arduino.cc/en/Refere...) calls the SPI library.  The docs for SD state:

The communication between the microcontroller and the SD card uses SPI, which takes place on digital pins 11, 12, and 13 (on most Arduino boards) or 50, 51, and 52 (Arduino Mega).

I believe I can find the mapping from "digital pins 11, 12, and 13" to the SERCOM module on my SAMD21 Xplained Pro board.  But what if I need to use a different SERCOM (recalling that I'll be using at least 3 different SERCOMs in my project)?  What is the correct "Arduino way" of handling this?  Do I create a custom version of the SPI library?

 

 

- rdp

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I doubt if you will ever get ASF4 support for this particular TFT controller.

Nor is it supported by the normal Arduino libraries.

 

So you will need to rely on the EastRising Arduino library and examples.

I am sure that it will work just fine but might appear a "bit slow".

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

fearless_fool wrote:
I believe I can find the mapping from "digital pins 11, 12, and 13" to the SERCOM module on my SAMD21 Xplained Pro board.  But what if I need to use a different SERCOM (recalling that I'll be using at least 3 different SERCOMs in my project)?  What is the correct "Arduino way" of handling this?  Do I create a custom version of the SPI library?

 

The "Arduino way" is to have multiple SPI objects for each SERCOM e.g. SPI (default), SPI1, SPI2, SPI3, ...

Regular Arduino boards have a 3x2 SPI header that uses the default SPI object.

So a regular Shield will pick up the SPI signals from this 3x2.   As well as the other signals from the Power, Analog, Digital headers, ...

 

Something like "SD.h" library will use the default SPI pins.   It will take some effort to use different SERCOM pins.

However other libraries will let you use SPI1, SPI2, SPI3, ...  i.e. different SERCOM pins.

 

Bear in mind that SPI is a bus.   So you will generally put multiple SPI devices on the same bus.

If you want to operate an SD card and a TFT with maximum throughput,  you would use DMA with separate SERCOMs.

The standard Arduino SAMD libraries will probably not use DMA.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David:

other libraries will let you use SPI1, SPI2, SPI3, ...  i.e. different SERCOM pins.

Are there well-known libraries for that, or do I need to write my own?  (I'm very familiar with SERCOM modules, but it would be great if there was an existing library module for that...

 

Bear in mind that SPI is a bus.   So you will generally put multiple SPI devices on the same bus.

As you point out, *ideally* like to set up DMA SERCOM to SERCOM communication to maximize throughput.   But Google is our friend, no?  Just this:

 

    https://github.com/adafruit/Adaf...

 

I'll see how far I can get with that...thanks for the help.

- rdp

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yep, SPI, Wire (i2c) and more are all built in libraries, most with examples. Don't think there are any "dual" examples in the library though, but the code for it is.

 

https://github.com/arduino/Ardui...

 

The "arduino" SAMD21 is called the zero, and should lead you to plenty of examples on their forums. MartinL is usually there with great info.

 

https://forum.arduino.cc/t/using...

 

One gotya with the DMA and a big display, DMA max transfers counter is limited to 2^16 bytes, words, or hwords. If you are moving more data than that, you've gotta link multiple descriptors.