Thread 中讨论的其他器件: SysConfig
大家好、
我正在尝试将 ADS1261与 C2000 (F28388D)配合使用。
我从 SPI 环回示例项目开始、并添加了可用的 ADS1261 C 库(sbac199)。
- 我的 SPI 配置如下:
协议: PROT POL0PHA1
STE 极性: SPISTE 低电平有效(正常)
仿真模式: 仿真在发送后停止
咬口率 1000000Hz
数据宽度:8位
使用 FIFO
- 我 使用 我的引脚的名称编辑了 interface.c 中的所有函数内容。
如果我尝试调用函数 ads1261_enable_internal_reference_example();当代码转至 setCS 时、我的引脚 nCS 不会变为低电平。
我按如下方式编辑了 setCS:
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);
}
它看起来像 GPIO_writePin (GPIO_PIN_SPIA_Sten、0);不起作用。
我使用 SysConfig 配置我的引脚分配、在 board.c 中、我看到 SPI_init 和 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); }
在我的主 函数 bars_init()中,调用该函数可以执行以下操作:
PinMux_init();
GPIO_init();
spi_init();
所以我不确定是什么问题,除了 SPI_init()之外,我还需要做什么呢? 您能否确认 GPIO_PIN_SPIA_STEN 是否是常规 GPIO、即使它在 SysConfig 中为 SPI 定义也是如此?
为了确保它不是硬件、我启动了一个新项目并将我的引脚19定义 为正常 GPIO、它工作正常、我可以切换引脚。
如果可以的话、我会把项目放出来。
谢谢你
e2e.ti.com/.../spi_5F00_ADS1261.zip