jscrane 12 Posted May 17, 2013 Share Posted May 17, 2013 Update to support the SPI driver and different SSI modules: - FatFs.begin(cs_pin) -> defaults to SSI2 and maximum SPI clock - FatFs.begin(cs_pin, clock_divider) -> SSI2 and SPI clock is divided by clock_divider. - FatFs.begin(cs_pin, clock_divider, module) -> SPI clock is divided by clock_divider, new SSI module selection - inherited print functions ( can be enabled in ffconf.h ) Pin 9 is used as CS inside the SPI library and it is toggled at each byte transferred so it can't be used by FatFs. I made some tests with CS control disabled inside the SPI lib and the transfer speed increases by ~50%. If the card can't be initialized, a possible solution is a 1K pull-up resitor from MISO to VDD. Because this library doesn't use low level access to hardware it shoul be compatible with further boards supportded by Energia (with enough RAM). Calin [EDIT] corrected the speed test example So reusing the SPI library as-is costs 50% in performance and wastes a GPIO? Suggests to me that SPI could use some refactoring love. Maybe split out a superclass for clients like FatFs and call into it from the existing class? Comments? Steve Quote Link to post Share on other sites
Rei Vilo 695 Posted July 3, 2013 Share Posted July 3, 2013 Hi Grant, Try to add a pull-up resitor of 1K to MISO pin. The original driver enables the weak pull-up for MISO, but in the the Energia SPI lib it is not enabled. You can also try to set the MISO pin with pinMode(MISO, INPUT_PULLUP) before SPI.begin. Regards, Calin @@calinp and @@OzGrant I'm experiencing the same issue with MISO from SPI port 0 and tried both of the suggested solutions, alas with no result. The logic analyser shows a flat HIGH signal. Have you been luckier with a working SPI(0) MISO? Thank you for your answers, so I can open an issue at the Energia repository. Quote Link to post Share on other sites
Rei Vilo 695 Posted July 3, 2013 Share Posted July 3, 2013 Just in case, the Stellaris® LM4F120H5QR Rev A1/A3/B0 Errata reads on top of page 27: GPIO 9.1 Some GPIO register bits default to the incorrect state Description: The AFSEL bits for the following pins are set at reset, resulting in the pins defaulting to their alternate function: This error in pin functionality may create pin conflict during any type of reset with the following signals: Signal PA4 Function SSI0Rx I/O Input Level Tristate and proposes as workaround Workaround: To reconfigure the pins to their intended reset state (GPIO Input, GPIODEN =0), software must clear the corresponding bits in the GPIOAFSEL and GPIODEN registers for the associated pins. For pins PD7 and PF0, software must clear the corresponding AFSEL bits using the register commit control procedures described in the Commit Control section in the General-Purpose Input/Outputs chapter in the data sheet. Note that PD7 and PF0 should be grounded, if possible, to prevent triggering an NMI. If that is not possible, an NMI handler must be implemented in case a High level is applied to PD7 or PF0 before they can be reconfigured. For PD7, the PMC7 assignment of 0x3 is not valid, so it does not cause any issues. However, for PF0, the PMC0 assignment of 0x3 specifies CAN0Rx. If the system design requires CAN0Rx to be on another pin, the PMC0 field for Port F must be assigned to another function or cleared. Silicon Revision Affected: A1 Fixed: Fixed on A3. Quote Link to post Share on other sites
Rei Vilo 695 Posted July 3, 2013 Share Posted July 3, 2013 No luck, same MISO issue with SPI3 port. Summary: SPI=SPI2 and SPI1 work fine Issues with SPI0 and SPI3: MISO not ok, even with pull-up resistor or with digitalMode(pinMISO, INPUT_PULLUP) as suggested Quote Link to post Share on other sites
calinp 24 Posted July 4, 2013 Author Share Posted July 4, 2013 Hi Rei, I have seen some erratic behavior when using SPI0, but I assumed it is because of my wiring and not driving the pins with enough current. The first library I posted used a SPI driver for the SD card taken from the Stelarisware and it worked fine. Also I checked the library only on SPI 0 and 2. Given your detailed analysis on this problem I think it is an initialisation problem that must be addressed to the Energia developers. Thank you for your effort. Calin Rei Vilo 1 Quote Link to post Share on other sites
Rei Vilo 695 Posted July 5, 2013 Share Posted July 5, 2013 @@calinp Thank you for your feedback. I filed a ticket at Energia GitHub repository. See https://github.com/energia/Energia/issues/255 Quote Link to post Share on other sites
Rei Vilo 695 Posted July 6, 2013 Share Posted July 6, 2013 To avoid any out-of-topic interferences with this thread dedicated to the FATFS library, I continue the conversation on a new thread, LaunchPad Stellaris on Energia — MISO Erratic Behaviour on SPI0 and SPI3. Thank you. Quote Link to post Share on other sites
Rei Vilo 695 Posted July 8, 2013 Share Posted July 8, 2013 SOLVED! Find solution at [sOLVED] LaunchPad Stellaris on Energia - MISO Erratic Behaviour on SPI0 and SPI3 Quote Link to post Share on other sites
Volodin Konstantin 0 Posted July 25, 2013 Share Posted July 25, 2013 Hi. I am developing fast datalogger, which should write adc data at full rateon some sort of storage. Is there any chance for Stellaris Launchpad to get 3 megabytes per second write speed on uSD card with SPI interface? Quote Link to post Share on other sites
calinp 24 Posted July 26, 2013 Author Share Posted July 26, 2013 Hi volodink, For that speed you have to use another microcontroller that supports "Four-Bit SD Bus Mode" (https://en.wikipedia.org/wiki/Secure_Digital#Technical_details). Regards, Calin Quote Link to post Share on other sites
Rei Vilo 695 Posted August 9, 2013 Share Posted August 9, 2013 How to open two files simultaneously? I need to read data from one file, process it and write the result on a second file. Quote Link to post Share on other sites
szymekrak1426459900 0 Posted August 9, 2013 Share Posted August 9, 2013 I am afraid this wrapper doesn't have mentioned functionality. But normal FatFs library can. I use it with Energia without any problems. I use diskio.c from one of the StellarisWare examples, modified to suit my connections. However, unmodified FatFs library requires using a timer. The SDFat library also works with Energia(some code changes are needed), but it is slower because of using things like digitalWrite. Attached file contains fatfs and SDFat from my libraries directory. They worked for me, but my SD card is connected to SSI3 and this is hardcoded. Wouldn't be hard to modify, I think. I can also share my working sketch, if needed. libraries.7z reaper7 and Rei Vilo 2 Quote Link to post Share on other sites
Rei Vilo 695 Posted August 9, 2013 Share Posted August 9, 2013 Has someone experienced memory leaks with this library? My program freezes after reading a file. Quote Link to post Share on other sites
Rei Vilo 695 Posted August 27, 2013 Share Posted August 27, 2013 Again, Has someone experienced memory leaks with this library?My program freezes after reading a file. Quote Link to post Share on other sites
szymekrak1426459900 0 Posted August 28, 2013 Share Posted August 28, 2013 Are you using the wrapper or normal FatFs? Here you can find memory usage of normal FatFs library: http://elm-chan.org/fsw/ff/en/appnote.html#memory Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.