Problems with converting Arduino Nano code over to Maple Mini. Help needed.


Buleste
Posts: 43
Joined: Sun Nov 06, 2016 12:19 pm

Re: Problems with converting Arduino Nano code over to Maple Mini. Help needed.

Post by Buleste » Tue Jan 31, 2017 12:42 pm

Thanks Steve. I'll get some of those and put everything on hold for the time being. Either that or try figure out how to convert the TimerOne calls on the Arduino versions of CASDuino/TZXDuino to HardwareTimer.

zmemw16
Posts: 1417
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Problems with converting Arduino Nano code over to Maple Mini. Help needed.

Post by zmemw16 » Tue Jan 31, 2017 2:25 pm

i followed a recommendation link from the forum, this is from my order
http://www.ebay.co.uk/itm/191736124794? ... EBIDX%3AIT

it is 3v3 ONLY, no regulator and has smt resistors, easy enough to lose them or just short circuit if required :)

at £0.60 for 2, i got 2 lots

have it wired in, not tried as yet.

stephen

Buleste
Posts: 43
Joined: Sun Nov 06, 2016 12:19 pm

Re: Problems with converting Arduino Nano code over to Maple Mini. Help needed.

Post by Buleste » Tue Jan 31, 2017 3:08 pm

In the mean time here's my conversion of Victors original wavplayer but for the ILI9341. Sadly the build in SD card has the same issues so you cannot use it with this programme as far as I can tell.
coos_wav_player_setModule2_ILI9341.zip
(4.44 KiB) Downloaded 20 times

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

Re: Problems with converting Arduino Nano code over to Maple Mini. Help needed.

Post by stevestrong » Tue Jan 31, 2017 3:18 pm

@Buleste,
let me conclude: your SD card and adapter are working fine using the SD info demo sketch but not working with your software, right?

Is your software the one you posted?
If yes, then it is a potential problem that there is no setModule() before initializing the SD card with SD.begin(...).
Also, you are using both SPI ports, but only one SPI port - for the display - is initialized in the setup() function. The one used by the SD card (SPI 1) seems to be initialized in another place, undefined time. I would suggest to init the card also in setup(). For testing, you could use the Sd card info example part which is working in the standalone version in setup(), too.

Alternatively, you could try to map the display to SPI 1 and the Sd card to SPI 2 without having to use the setModule() function. For this, use the latest SdFat beta from greiman, because it can be set to use SPI_2. I am using his version directly from github and it works:

Code: Select all

SdFat sd(2); // use SPI 2 to access SD card

Buleste
Posts: 43
Joined: Sun Nov 06, 2016 12:19 pm

Re: Problems with converting Arduino Nano code over to Maple Mini. Help needed.

Post by Buleste » Tue Jan 31, 2017 4:00 pm

stevestrong wrote:@Buleste,
let me conclude: your SD card and adapter are working fine using the SD info demo sketch but not working with your software, right?

Is your software the one you posted?
If yes, then it is a potential problem that there is no setModule() before initializing the SD card with SD.begin(...).
Also, you are using both SPI ports, but only one SPI port - for the display - is initialized in the setup() function. The one used by the SD card (SPI 1) seems to be initialized in another place, undefined time. I would suggest to init the card also in setup(). For testing, you could use the Sd card info example part which is working in the standalone version in setup(), too.

Alternatively, you could try to map the display to SPI 1 and the Sd card to SPI 2 without having to use the setModule() function. For this, use the latest SdFat beta from greiman, because it can be set to use SPI_2. I am using his version directly from github and it works:

Code: Select all

SdFat sd(2); // use SPI 2 to access SD card
TBH all I did was change the Victors original code (can be found in MapleCoOS116 examples) for the ILI9136C to ILI9341 to get the display working and didn't think to check how the original code accessed the SD card and assumed that he had it set up to SPI 1. My bad.

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

Re: Problems with converting Arduino Nano code over to Maple Mini. Help needed.

Post by victor_pv » Tue Jan 31, 2017 4:31 pm

Sorry I totally forgot about that example using 2 SPI ports.

The way the example is set, should be using SPI1 for the card and SPI2 for the screen:

Code: Select all

...
  SPI.setModule(2);
  tft.begin();
  ...
I used it to test the setModule functions when Roger added them to the core, so I am almost sure I first wrote another version that doesn't use setModule and just goes does all thru SPI1, and if I remember right I had another version that used both SPI1 and SPI2 but without using set module.

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

Re: Problems with converting Arduino Nano code over to Maple Mini. Help needed.

Post by victor_pv » Tue Jan 31, 2017 4:36 pm

stevestrong wrote:@Buleste,
let me conclude: your SD card and adapter are working fine using the SD info demo sketch but not working with your software, right?

Is your software the one you posted?
If yes, then it is a potential problem that there is no setModule() before initializing the SD card with SD.begin(...).
Also, you are using both SPI ports, but only one SPI port - for the display - is initialized in the setup() function. The one used by the SD card (SPI 1) seems to be initialized in another place, undefined time. I would suggest to init the card also in setup(). For testing, you could use the Sd card info example part which is working in the standalone version in setup(), too.

Alternatively, you could try to map the display to SPI 1 and the Sd card to SPI 2 without having to use the setModule() function. For this, use the latest SdFat beta from greiman, because it can be set to use SPI_2. I am using his version directly from github and it works:

Code: Select all

SdFat sd(2); // use SPI 2 to access SD card
Steve, the SPI object is created automatically by the core, using SPI1 by default. Since the sdcard is working in SPI1, that SPI port is initialized by the core with the default settings, and the sd.begin line just changes the port speed to the maximum:

Code: Select all

!SD.begin(SD_ChipSelectPin, SPI_CLOCK_DIV2
The tft screen is the one using SPI2, which could be the one that needs settings other than default, but that would affect the screen.

Buleste
Posts: 43
Joined: Sun Nov 06, 2016 12:19 pm

Re: Problems with converting Arduino Nano code over to Maple Mini. Help needed.

Post by Buleste » Tue Jan 31, 2017 4:45 pm

As it happens I've just killed my Maple Mini so everythings on hold now anyway. Lol

However even though I don't have a board to test on I will be carrying on with trying to convert the TimerOne library calls from TZXDuino/CASDuino to HardwareTimer to see if I can at least get them to verify.

EDIT:

For those interested the codes I'm trying to translate from Arduino programmes to SMT32 are the following
MapleTape which I have already started to alter so that is works on Maple Mini and is compiling but due to the SD and now the Mini issues isn't working as of yet.
https://mega.nz/#!vVNlDTwT!ro5dbqHEGdfv ... ew9tCo7SHo

CASMaple I haven't altered yet and is still in it's Arduino working form
https://mega.nz/#!bUkhBCzB!lvNOBlQaIp1a ... Yk47Nxus2w

TZXMaple is the same story as CASMaple but because the code is so similar if I get one working then the other one should work too.
https://mega.nz/#!6Md1hTDI!5rk7c6fWwChG ... dioJGyDB0E
Last edited by Buleste on Tue Jan 31, 2017 5:26 pm, edited 1 time in total.

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

Re: Problems with converting Arduino Nano code over to Maple Mini. Help needed.

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

Buleste wrote:As it happens I've just killed my Maple Mini so everythings on hold now anyway. Lol

However even though I don't have a board to test on I will be carrying on with trying to convert the TimerOne library calls from TZXDuino/CASDuino to HardwareTimer to see if I can at least get them to verify.
What's the TimerOne library for? I haven't used it before.
A note of advice, when working on my port of the TMRPCM library I found HardwareTimer provides only the most basic features of the timers, but there are some core functions that can do more, and then all registers and bits are defined in the core, so for anything advanced other than generate PWM output and trigger an interrupt, you should go and have a good read on the stm32f1 reference manual and learn how the timer peripherals work, then you can go setting registers as you need.

BTW, there is a thread called something like "My maple mini just let go of the magic smoke" that shows some issues with the hardware, and some could be corrected. I started it when I thought I had burnt the MCU, and found out it was just the voltage regulator and a diode and was able to replace them.

Post Reply