• 0
findAUsername

Use MTDS with arduino ARM processor

Question

Hi everyone,

I just bought a MTDS (https://reference.digilentinc.com/reference/add-ons/mtdshield/start)

I tried to use on an arduino Duo (arm cortex M3) and I got this error :

C:\Program Files (x86)\Arduino\libraries\mtds\MtdsHal.cpp:326:2: error: #error "No supported processor defined"

 #error "No supported processor defined"

So I have checked MtdsHal.cpp at line 326 and I saw that the SPI is set for PIC or AVR processor.

Is there a solution for arm processor ?

Thanks

 

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi @findAUsername,

The Arduino Duo is not one of the processors added in the MtdsHal.cpp at line 326. You will need to add the Arduino duo processor to the file on line 324. Something like:

#elif defined(__SAM3X8E__)
    /* We are building for an Arduino board using an AVR processor.
    ** Init the SPI controller with the following conditions:
    **        SPIE = 0    : SPI interrupts disabled
    **        SPE = 1        : SPI enabled
    **        DORD = 0    : shift directions MSB first
    **        MSTR = 1    : Master mode
    **        CPOL = 0    : SPI mode 0
    **        CPHA = 0
    **        SPR1 = 0    : SCK frequency = Fosc/4
    **        SPR0 = 0
    **
    **        SPI2X = 0
    */
    SPCR = _BV(SPE) | _BV(MSTR);
    SPSR = _BV(SPI2X);

thank you,

Jon

 

 

Share this post


Link to post
Share on other sites
  • 0

Hi jpeyron,

Thank you for your answer. So I added this code and also in function bool MtdsHalSpiReady()  I copy paste the code for AVR and change the defined with SAM3X8E. Same in function uint8_t MtdsHalPutSpiByte(uint8_t bSnd) .

Now it goes in else if (SAM3X8E), however nothing is declared in the scope. I got this type of error:
 

C:\Program Files (x86)\Arduino\libraries\mtds\MtdsHal.cpp: In function 'void MtdsHalInitSpi(uint32_t, uint32_t)':

C:\Program Files (x86)\Arduino\libraries\mtds\MtdsHal.cpp:339:2: error: 'SPCR' was not declared in this scope

  SPCR = _BV(SPE) | _BV(MSTR);

  ^

C:\Program Files (x86)\Arduino\libraries\mtds\MtdsHal.cpp:339:13: error: 'SPE' was not declared in this scope

  SPCR = _BV(SPE) | _BV(MSTR);

             ^

C:\Program Files (x86)\Arduino\libraries\mtds\MtdsHal.cpp:339:16: error: '_BV' was not declared in this scope

  SPCR = _BV(SPE) | _BV(MSTR);

                ^

C:\Program Files (x86)\Arduino\libraries\mtds\MtdsHal.cpp:339:24: error: 'MSTR' was not declared in this scope

  SPCR = _BV(SPE) | _BV(MSTR);

                        ^

C:\Program Files (x86)\Arduino\libraries\mtds\MtdsHal.cpp:340:2: error: 'SPSR' was not declared in this scope

  SPSR = _BV(SPI2X);

  ^

C:\Program Files (x86)\Arduino\libraries\mtds\MtdsHal.cpp:340:13: error: 'SPI2X' was not declared in this scope


  SPSR = _BV(SPI2X);

             ^

 

Do you have an idea, how to declared those things ?

Thank you

 

Share this post


Link to post
Share on other sites
  • 0

Hi @findAUsername,

I was able to alter the MtdsHal.cpp file to include the SAM3X8E processor. The sketch will now compile without issues.  I did not make any changes to the board with the altered file. We do not have a Arduino DUE so i would not be able to test if it works on the DUE or if you will need to make changes to the board definitions. I have attached the altered file.

thank you,

Jon

MtdsHal.cpp

Share this post


Link to post
Share on other sites
  • 0

Hi jpeyron,

Yes in fact it is compiling without error. I try to run one of the script give with the lib (MyDispDemo1) but mydisp.begin(); return all the time false so I am stuck in the first while (line 96).

And the pins are the same between Duo and Uno for this type of shield, so I think that I should good connected.

Thank you

Share this post


Link to post
Share on other sites
  • 0

HI @findAUsername,

To clarify you are using the Arduino DUE(here) correct? To also confirm that you added the contents in the resource folder to an sd card and have that sd card inserted in the sd card slot of the MTDS?

You will need to initialize the spi controller for the Arduino DUE  the AVR was changed to:
    **        SPIE = 0    : SPI interrupts disabled
    **        SPE = 1        : SPI enabled
    **        DORD = 0    : shift directions MSB first
    **        MSTR = 1    : Master mode
    **        CPOL = 0    : SPI mode 0
    **        CPHA = 0
    **        SPR1 = 0    : SCK frequency = Fosc/4
    **        SPR0 = 0
    **
    **        SPI2X = 0
    */

I am not sure what specific spi setting you will need for the DUE. When you have detirmined what settings you will need to add the new settings on line 339 of the altered MtdsHal.cpp file. The functions MtdsHalPutSpiByte() and MtdsHalSpiReady() might need some addition added code as well. 

You might need to alter the Hal.h  around line 80 where a spi frequency is defined and in the MyDisp.h defines the ram based on the number of buttons on the board. 

We only added Ardunio AVR processor support and not the SAM3X8E . We do not have a Aduino DUE for testing, so we will not be able to readily offer a lot of support in this regard.

thank you,

Jon

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now