Rei Vilo 695 Posted July 6, 2013 Share Posted July 6, 2013 SOLVED — see http://forum.stellarisiti.com/topic/675-solved launchpad-stellaris-on-energia-miso-erratic-behaviour-on-spi0-and-spi3/?p=3462 This thread continues a question I raised in [Energia Library] Stellaris Launchpad FatFs Energia library. I'm experiencing an issue with MISO from SPI port 0: no signal coming to the MCU. 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 I tried both of the suggested solutions, alas with no result. The logic analyser shows a flat HIGH signal. Same for SPI3. 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
Rei Vilo 695 Posted July 6, 2013 Author Share Posted July 6, 2013 Digging into TI documentation, 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 6, 2013 Author Share Posted July 6, 2013 Now, the MCUs on my two Stellaris LaunchPads aren't labelled LM4F120H5QR but LX4F120H5QR. As I was an early adopter, were the MCUs from a pre-production batch? Quote Link to post Share on other sites
Rei Vilo 695 Posted July 6, 2013 Author Share Posted July 6, 2013 Two questions: Is this issue hardware related, i.e with the LX4F120H5QR? Or or the issue specific to Energia configuration? I filed a ticket at Energia GitHub repository. See https://github.com/energia/Energia/issues/255 Quote Link to post Share on other sites
calinp 24 Posted July 6, 2013 Share Posted July 6, 2013 Hi Rei, Did you checked miso, mosi, sclk, ss signals during a byte transmissio on all SPI modules ? Maybe the SPI mode or the SS pin are not configured correctly and the slave does not recognize what is sent to it. Quote Link to post Share on other sites
Rei Vilo 695 Posted July 6, 2013 Author Share Posted July 6, 2013 @@calinp, thank you for your suggestion. Unfortunately yes, I used a logic analyser with the 4 lines, SCK MISO MOSI SS. MISO is flat HIGH on SPI 0 and 3. Quote Link to post Share on other sites
Rei Vilo 695 Posted July 8, 2013 Author Share Posted July 8, 2013 Many thanks to @@reaper7 who helped me and fixed the problem! Actually, it was a problem with the initialisation of the SPI ports. Please find for the StellarPad. the link to the SPI library he updated http://forum.stellarisiti.com/topic/620-two-spi-modules/?p=3346 and combined with a fast digitalWrite() library SPI_all_ports_LM4F.zip Here is a comparison of the times, all in us —1 s = 10^9 us— measured with a Saleae Logic16 analyser at 100 MHz, ±0,01 us. Comma as decimal separator. digitalWrite(HIGH) digitalWrite(LOW) = 0,73 us per cyclesetHIGH() - setLOW() = 0,26 us per cyclepulseHIGH() = 0,19 us per pulsepulseLOW() = 0,19 us per pulsepulseLOW() x2 = 0,19 us per pulse and 0,26 us between pulses Saleae trace FastDigitalWrite.logicdata.zip reaper7 1 Quote Link to post Share on other sites
reaper7 67 Posted July 8, 2013 Share Posted July 8, 2013 @@Rei Vilo - so, new version (your files above: SPI_all_ports_LM4F.zip) will no longer need in SPI.h and SPI.cpp: // Stellarpad-specific functions void setModule(unsigned long); // module void setModule(unsigned long, unsigned long); // module, sspin because all modules are defined and SPI is declared as SPI2 Quote Link to post Share on other sites
NPlayer 0 Posted September 9, 2014 Share Posted September 9, 2014 Hi! I'm going to try this out, I need two fully functional SPI ports, but I have a Tiva-C board, TM4C123G exactly. Will all this stuff work with it? Thank you! 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.