Other Parts Discussed in Thread: SYSCONFIG
Hi everyone,
I am trying to get to work the ADS1261 with a C2000 (F28388D).
I started from SPI loopback example project and add the ADS1261 C library available (sbac199).
- My SPI config is as below:
Protocol : PROT POL0PHA1
STE Polarity: SPISTE is active low (normal)
Emulation Mode: EMULATION STOP AFTER TRANSMIT
Bite Rate 1000000Hz
Data Width: 8bit
Use FIFO
- I edited all of the function contents inside the interface.c with the name of my pins.
If I try to call the function ads1261_enable_internal_reference_example(); when the code goes to setCS my pin nCS does not goes low.
I edited setCS as follow:
void setCS(bool state)
{
/* --- INSERT YOUR CODE HERE ---
* This function sets the "nCS" GPIO pin state,
* according to the input argument, and delays for 50 ns.
*
* The following code shows an example using TivaWare™...
*/
if (state)
{
/* Sets the nCS pin HIGH */
//GPIOPinWrite(SPI_STEn, nCS_PIN, nCS_PIN);
GPIO_writePin(GPIO_PIN_SPIA_STEN,1);
}
else
{
/* Sets the nCS pin LOW */
GPIO_writePin(GPIO_PIN_SPIA_STEN,0);
GPIO_writePin(GPIO3,0); //DEBUG
}
/* td(SCCS)/td(CSSC) delay */
DEVICE_DELAY_US(8);
//SysCtlDelay(2);
}
it looks like GPIO_writePin(GPIO_PIN_SPIA_STEN,0); does not work.
I use SysConfig to configure my pinout, in board.c I see the SPI_init and Pinmux_init:/*
* Copyright (c) 2020 Texas Instruments Incorporated - http://www.ti.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "board.h"
void Board_init()
{
EALLOW;
PinMux_init();
GPIO_init();
SPI_init();
EDIS;
}
void PinMux_init()
{
//GPIO40 -> NDRDY Pinmux
GPIO_setPinConfig(GPIO_40_GPIO40);
//GPIO96 -> nRESET Pinmux
GPIO_setPinConfig(GPIO_96_GPIO96);
//GPIO41 -> nPWDN Pinmux
GPIO_setPinConfig(GPIO_41_GPIO41);
//GPIO98 -> START Pinmux
GPIO_setPinConfig(GPIO_98_GPIO98);
//GPIO34 -> LED_34 Pinmux
GPIO_setPinConfig(GPIO_34_GPIO34);
//GPIO31 -> LED_31 Pinmux
GPIO_setPinConfig(GPIO_31_GPIO31);
//GPIO3 -> GPIO3 Pinmux
GPIO_setPinConfig(GPIO_3_GPIO3);
//SPIA -> mySPI0 Pinmux
GPIO_setPinConfig(GPIO_16_SPIA_SIMO);
GPIO_setPinConfig(GPIO_17_SPIA_SOMI);
GPIO_setPinConfig(GPIO_18_SPIA_CLK);
GPIO_setPinConfig(GPIO_19_SPIA_STEN);
}
void GPIO_init(){
//NDRDY initialization
GPIO_setDirectionMode(NDRDY, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(NDRDY, GPIO_PIN_TYPE_STD);
GPIO_setMasterCore(NDRDY, GPIO_CORE_CPU1);
GPIO_setQualificationMode(NDRDY, GPIO_QUAL_SYNC);
//nRESET initialization
GPIO_setDirectionMode(nRESET, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(nRESET, GPIO_PIN_TYPE_STD);
GPIO_setMasterCore(nRESET, GPIO_CORE_CPU1);
GPIO_setQualificationMode(nRESET, GPIO_QUAL_SYNC);
//nPWDN initialization
GPIO_setDirectionMode(nPWDN, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(nPWDN, GPIO_PIN_TYPE_STD);
GPIO_setMasterCore(nPWDN, GPIO_CORE_CPU1);
GPIO_setQualificationMode(nPWDN, GPIO_QUAL_SYNC);
//START initialization
GPIO_setDirectionMode(START, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(START, GPIO_PIN_TYPE_STD);
GPIO_setMasterCore(START, GPIO_CORE_CPU1);
GPIO_setQualificationMode(START, GPIO_QUAL_SYNC);
//LED_34 initialization
GPIO_setDirectionMode(LED_34, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(LED_34, GPIO_PIN_TYPE_STD);
GPIO_setMasterCore(LED_34, GPIO_CORE_CPU1);
GPIO_setQualificationMode(LED_34, GPIO_QUAL_SYNC);
//LED_31 initialization
GPIO_setDirectionMode(LED_31, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(LED_31, GPIO_PIN_TYPE_STD);
GPIO_setMasterCore(LED_31, GPIO_CORE_CPU1);
GPIO_setQualificationMode(LED_31, GPIO_QUAL_SYNC);
//GPIO3 initialization
GPIO_setDirectionMode(GPIO3, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(GPIO3, GPIO_PIN_TYPE_STD);
GPIO_setMasterCore(GPIO3, GPIO_CORE_CPU1);
GPIO_setQualificationMode(GPIO3, GPIO_QUAL_SYNC);
}
void SPI_init()
{
//mySPI0 initialization
SPI_disableModule(mySPI0_BASE);
SPI_setConfig(mySPI0_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA1,
SPI_MODE_MASTER, 1000000, 8);
SPI_enableFIFO(mySPI0_BASE);
SPI_setFIFOInterruptLevel(mySPI0_BASE, SPI_FIFO_TXEMPTY, SPI_FIFO_RXEMPTY);
SPI_disableLoopback(mySPI0_BASE);
SPI_setEmulationMode(mySPI0_BASE, SPI_EMULATION_STOP_AFTER_TRANSMIT);
SPI_enableModule(mySPI0_BASE);
}
In my main Boars_init(); is called to do:
PinMux_init();
GPIO_init();
SPI_init();
So I am not sure what is wrong, do I need to do something else than just SPI_init()? Can you confirm GPIO_PIN_SPIA_STEN is a regular GPIO even if its defined for SPI in sysConfig?
To be sure it was not hardware I started a new project and define my pin19 as a normal GPIO and it works OK I can toggle the pin.
I put my project if it can help.
Thank you