Thread 中讨论的其他器件:EK-TM4C1294XL、 TM4C123
您好!
当 SSI0模块与 ADXL345连接时、它会在超级终端上生成信号和数据、
但是、当取代 SSI2或其他模块而不是 SSI0时、根本无法获取数据或信号
请建议修复此问题。
谢谢你。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好!
当 SSI0模块与 ADXL345连接时、它会在超级终端上生成信号和数据、
但是、当取代 SSI2或其他模块而不是 SSI0时、根本无法获取数据或信号
请建议修复此问题。
谢谢你。
您好!
它应该在整个代码中将 SSI0_BASE 替换为 SSI2_base、还应该将必须为 SSI2配置的 GPIO 引脚替换为 SSI2_base。 您可能会错过一些东西。 例如、您可能已将以下引脚用于 SSI0。
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOA);
GPIOPinConfigure (GPIO_PA2_SSI0CLK);
GPIOPinConfigure (GPIO_PA3_SSI0FSS);
GPIOPinConfigure (GPIO_PA4_SSI0XDAT0);
GPIOPinConfigure (GPIO_PA5_SSI0XDAT1);
GPIOPinTypeSSI (GPIO_Porta_base、GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 |
GPIO_PIN_2);
对于 SSI2、您必须更改为以下内容。
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOD);
GPIOPinConfigure (GPIO_PD3_SSI2CLK);
GPIOPinConfigure (GPIO_PD2_SSI2FSS);
GPIOPinConfigure (GPIO_PD1_SSI2XDAT0);
GPIOPinConfigure (GPIO_PD0_SSI2XDAT1);
GPIOPinTypeSSI (GPIO_PORTD_base、GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 |
GPIO_PIN_0);
您好!
[~引脚 userid="93620" URL"/support/microcontrollers/arm-based microcontrollers-group/arm -based-microcontrollers/f/arm based-microcontrollers-forum/1103610/tm4c1294ncpdt-data-not generated-when -SSI2-module-is-interfinded-with sensor/4088542#4088542"GPIOPinConfigure (GPIO_PD3_SSI2CLK);
GPIOPinConfigure (GPIO_PD2_SSI2FSS);
GPIOPinConfigure (GPIO_PD1_SSI2XDAT0);
GPIOPinConfigure (GPIO_PD0_SSI2XDAT1);
GPIOPinTypeSSI (GPIO_PORTD_base、GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 |
GPIO_PIN_0);
正如您提到的、我更改了代码、但对我来说不起作用。 即使我也尝试将 SSI0更改为 SSI3、但无法接收任何数据或信号。
谢谢你
您为什么不尝试这个 SSI2的简单示例。 我在示波器上看到 SSI2CLK 和 SSI2TX 信号。
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/ssi.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/rom_map.h"
#include "driverlib/rom.h"
#include "utils/uartstdio.h"
//*****************************************************************************
//
// Number of bytes to send and receive.
//
//*****************************************************************************
#define NUM_SSI_DATA 3
//*****************************************************************************
//
// Configure SSI0 in master Freescale (SPI) mode. This example will send out
// 3 bytes of data, then wait for 3 bytes of data to come in. This will all be
// done using the polling method.
//
//*****************************************************************************
int
main(void)
{
uint32_t ui32SysClock;
uint32_t pui32DataTx[NUM_SSI_DATA];
uint32_t pui32DataRx[NUM_SSI_DATA];
uint32_t ui32Index;
//
// Set the clocking to run directly from the external crystal/oscillator.
// TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
// crystal on your board.
//
ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL), 120000000);
//
// The SSI0 peripheral must be enabled for use.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinConfigure(GPIO_PD3_SSI2CLK);
GPIOPinConfigure(GPIO_PD2_SSI2FSS);
GPIOPinConfigure(GPIO_PD1_SSI2XDAT0);
GPIOPinConfigure(GPIO_PD0_SSI2XDAT1);
GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 |
GPIO_PIN_0);
SSIConfigSetExpClk(SSI2_BASE, ui32SysClock, SSI_FRF_MOTO_MODE_0,
SSI_MODE_MASTER, 10000000, 16);
//
// Enable the SSI0 module.
//
SSIEnable(SSI2_BASE);
//
// Read any residual data from the SSI port. This makes sure the receive
// FIFOs are empty, so we don't read any unwanted junk. This is done here
// because the SPI SSI mode is full-duplex, which allows you to send and
// receive at the same time. The SSIDataGetNonBlocking function returns
// "true" when data was returned, and "false" when no data was returned.
// The "non-blocking" function checks if there is any data in the receive
// FIFO and does not "hang" if there isn't.
//
while(SSIDataGetNonBlocking(SSI2_BASE, &pui32DataRx[0]))
{
}
//
// Initialize the data to send.
//
pui32DataTx[0] = 's';
pui32DataTx[1] = 'p';
pui32DataTx[2] = 'i';
//
// Send 3 bytes of data.
//
while (1)
{
for (ui32Index = 0; ui32Index<3; ui32Index++)
{
//
// Send the data using the "blocking" put function. This function
// will wait until there is room in the send FIFO before returning.
// This allows you to assure that all the data you send makes it into
// the send FIFO.
//
SSIDataPut(SSI2_BASE, pui32DataTx[ui32Index]);
}
}
//
// Return no errors
//
return(0);
}感谢您的编码、我 能够使用逻辑分析仪看到 SSI2CLK、SSI2FSS 和 SSI2TX 信号。 当我将您的代码与 C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\ssi_master_slave_xfer 示例代码进行比较时、这里使用了 SSI1IntHandler 函数。 在 startup_ccs.c 中 声明了代码 SSI1IntHandler。 但 您的代码不包含此函数。 我删除 了 startup_ccs.c 中的 SSI1IntHandler 声明 以获取 SSI2信号。 在 SPI 通信期间是否有必要使用此功能?
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "inc/hw_ints.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/ssi.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
//****************************************************************************
//
// The variable g_ui32SysClock contains the system clock frequency in Hz.
//
//****************************************************************************
uint32_t g_ui32SysClock;
//*****************************************************************************
//
// Global flag to indicate data has been received.
//
//*****************************************************************************
volatile uint32_t g_breceiveFlag = 0;
//*****************************************************************************
//
// Number of bytes to send and receive.
//
//*****************************************************************************
#define NUM_SSI_DATA 4
//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
//*****************************************************************************
//
// Configure the UART and its pins. This must be called before UARTprintf().
//
//*****************************************************************************
void
ConfigureUART(void)
{
//
// Enable the GPIO Peripheral used by the UART.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Enable UART0.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
//
// Configure GPIO Pins for UART mode.
//
ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Initialize the UART for console I/O.
//
UARTStdioConfig(0, 115200, g_ui32SysClock);
}
//*****************************************************************************
//
// When the received FIFO is half-full, an interrupt will be generated.
//
//*****************************************************************************
void
SSI1IntHandler(void)
{
uint32_t ui32Status;
//
// Read SSIMIS (SSI Masked Interrupt Status).
//
ui32Status = MAP_SSIIntStatus(SSI1_BASE, true);
//
// Clear the SSI interrupt.
//
MAP_SSIIntClear(SSI1_BASE, ui32Status);
//
// Turn off the RX FIFO interrupt.
//
MAP_SSIIntDisable(SSI1_BASE, SSI_RXFF);
g_breceiveFlag = 1;
}
//*****************************************************************************
//
// Configure SSI0 in Quad-SSI master Freescale (SPI) mode and SSI1 in Quad-SSI
// slave mode. The SSI0 will send out 4 bytes of data in advanced Quad mode
// and the SSI1 slave will receive the 4 bytes of data also in Quad-mode. The
// slave will generate interrupt upon receiving the 4 bytes of data.
//
//*****************************************************************************
int
main(void)
{
uint32_t pui32DataTx[NUM_SSI_DATA];
uint32_t pui32DataTx1[NUM_SSI_DATA];
uint32_t pui32DataRx[NUM_SSI_DATA];
uint32_t ui32Index;
//
// Run from the PLL at 120 MHz.
// Note: SYSCTL_CFG_VCO_240 is a new setting provided in TivaWare 2.2.x and
// later to better reflect the actual VCO speed due to SYSCTL#22.
//
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_240), 120000000);
//
// Set up the serial console to use for displaying messages.
//
ConfigureUART();
//
// Display the setup on the console.
//
UARTprintf("SSI Master-Slave Transfer Example.\n");
UARTprintf("Mode: Legacy SPI\n");
UARTprintf("Data: 8-bit\n\n");
//
// The SSI0 and SSI1 peripheral must be enabled for use.
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
//
// For this example SSI0 is used with PortA[5:2]. The SSI1 uses
// PortB and PortE for the SSICLK, SSIFss and the TX/RX pins.
// GPIO ports need to be enabled so those pins can be used.
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
//
// Configure the pin muxing for SSI0 functions on PA[5:2].
// Configure the pin muxing for SSI1 functions on PB and PE.
//
MAP_GPIOPinConfigure(GPIO_PA2_SSI0CLK);
MAP_GPIOPinConfigure(GPIO_PA3_SSI0FSS);
MAP_GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);
MAP_GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);
MAP_GPIOPinConfigure(GPIO_PB5_SSI1CLK);
MAP_GPIOPinConfigure(GPIO_PB4_SSI1FSS);
MAP_GPIOPinConfigure(GPIO_PE4_SSI1XDAT0);
MAP_GPIOPinConfigure(GPIO_PE5_SSI1XDAT1);
//
// Configure the GPIO settings for the SSI pins. This function also gives
// control of these pins to the SSI hardware. Consult the data sheet to
// see which functions are allocated per pin.
// The pins are assigned as follows:
// SSI0
// PA5 - SSI0RX
// PA4 - SSI0TX
// PA3 - SSI0Fss
// PA2 - SSI0CLK
// SSI1
// PE5 - SSI1RX
// PE4 - SSI1TX
// PB4 - SSI1Fss
// PB5 - SSI1CLK
//
MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 | GPIO_PIN_2);
MAP_GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_5 | GPIO_PIN_4 );
MAP_GPIOPinTypeSSI(GPIO_PORTE_BASE, GPIO_PIN_5 | GPIO_PIN_4 );
//
// Configure and enable the SSI0 port for SPI master mode. Use SSI0,
// system clock supply, idle clock level low and active low clock in legacy
// Freescale SPI mode, master mode, 2MHz SSI frequency, and 8-bit data.
// For SPI mode, you can set the polarity of the SSI clock when the SSI
// unit is idle. You can also configure what clock edge you want to
// capture data on. Please reference the datasheet for more information on
// the different SPI modes.
//
MAP_SSIConfigSetExpClk(SSI0_BASE, g_ui32SysClock, SSI_FRF_MOTO_MODE_0,
SSI_MODE_MASTER, 2000000, 8);
//
// Configure and enable the SSI1 port for SPI slave mode with matching
// SPI mode, clock speed, and data size parameters as the master.
//
MAP_SSIConfigSetExpClk(SSI1_BASE, g_ui32SysClock, SSI_FRF_MOTO_MODE_0,
SSI_MODE_SLAVE, 2000000, 8);
//
// Enable processor interrupts.
//
MAP_IntMasterEnable();
//
// Enable SSI1 interrupt on RX FIFO full.
//
MAP_SSIIntEnable(SSI1_BASE, SSI_RXFF);
//
// Enable the SSI1 interrupts on the processor (NVIC).
//
IntEnable(INT_SSI1);
//
// Enable the SSI0 and SSI1 modules.
//
MAP_SSIEnable(SSI0_BASE);
MAP_SSIEnable(SSI1_BASE);
//
// Read any residual data from the SSI port. This makes sure the receive
// FIFOs are empty, so we don't read any unwanted junk. This is done here
// because the SPI SSI mode is full-duplex, which allows you to send and
// receive at the same time. The SSIDataGetNonBlocking function returns
// "true" when data was returned, and "false" when no data was returned.
// The "non-blocking" function checks if there is any data in the receive
// FIFO and does not "hang" if there isn't.
//
while(MAP_SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx[0]))
{
}
while(MAP_SSIDataGetNonBlocking(SSI1_BASE, &pui32DataRx[0]))
{
}
//
// Initialize the data to send.
//
pui32DataTx[0] = 'T';
pui32DataTx[1] = 'I';
pui32DataTx[2] = 'V';
pui32DataTx[3] = 'A';
pui32DataTx1[0] = 'Q';
pui32DataTx1[1] = 'S';
pui32DataTx1[2] = 'S';
pui32DataTx1[3] = 'I';
//
// Display indication that the SSI0/SSI1 is transmitting data.
//
UARTprintf("SSI0 Sent:\n ");
UARTprintf("'T' 'I' 'V' 'A' \n");
UARTprintf("SSI1 Sent:\n ");
UARTprintf("'Q' 'S' 'S' 'I' \n");
//
// Send 4 bytes of data.
//
for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)
{
//
// Prepare data to send from the slave.
//
MAP_SSIDataPut(SSI1_BASE, pui32DataTx1[ui32Index]);
//
// Send the data using the "blocking" put function. This function
// will wait until there is room in the send FIFO before returning.
// This allows you to assure that all the data you send makes it into
// the send FIFO.
//
MAP_SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
}
//
// Wait until SSI1 receives the half-full interrupt on the RX FIFO.
//
while (g_breceiveFlag == 0);
//
// Display indication that the SSI0 is receiving data.
//
UARTprintf("\nSSI0 Received:\n ");
//
// Receive 4 bytes of data.
//
for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)
{
//
// Receive the data using the "blocking" Get function. This function
// will wait until there is data in the receive FIFO before returning.
//
MAP_SSIDataGet(SSI0_BASE, &pui32DataRx[ui32Index]);
//
// Since we are using 8-bit data, mask off the MSB.
//
pui32DataRx[ui32Index] &= 0x00FF;
//
// Display the data that SSI0 received.
//
UARTprintf("'%c' ", pui32DataRx[ui32Index]);
}
//
// Display indication that the SSI1 is receiving data.
//
UARTprintf("\nSSI1 Received:\n ");
//
// Receive 4 bytes of data.
//
for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)
{
//
// Receive the data using the "blocking" Get function. This function
// will wait until there is data in the receive FIFO before returning.
//
MAP_SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index]);
//
// Since we are using 8-bit data, mask off the MSB.
//
pui32DataRx[ui32Index] &= 0x00FF;
//
// Display the data that SSI1 received.
//
UARTprintf("'%c' ", pui32DataRx[ui32Index]);
}
//
// Display indication that the SSI1 is receiving data.
//
UARTprintf("\n\nMaster-Slave Transfer Complete.\n");
//
// Return no errors.
//
while (1);
}
//*****************************************************************************
//
// startup_ccs.c - Startup code for use with TI's Code Composer Studio.
//
// Copyright (c) 2019-2020 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 2.2.0.295 of the EK-TM4C1294XL Firmware Package.
//
//*****************************************************************************
#include <stdint.h>
#include "inc/hw_nvic.h"
#include "inc/hw_types.h"
//*****************************************************************************
//
// Forward declaration of the default fault handlers.
//
//*****************************************************************************
void ResetISR(void);
static void NmiSR(void);
static void FaultISR(void);
static void IntDefaultHandler(void);
//*****************************************************************************
//
// External declaration for the reset handler that is to be called when the
// processor is started
//
//*****************************************************************************
extern void _c_int00(void);
//*****************************************************************************
//
// Linker variable that marks the top of the stack.
//
//*****************************************************************************
extern uint32_t __STACK_TOP;
//*****************************************************************************
//
// External declaration for the interrupt handler used by the application.
//
//*****************************************************************************
extern void SSI1IntHandler(void);
//*****************************************************************************
//
// The vector table. Note that the proper constructs must be placed on this to
// ensure that it ends up at physical address 0x0000.0000 or at the start of
// the program if located at a start address other than 0.
//
//*****************************************************************************
#pragma DATA_SECTION(g_pfnVectors, ".intvecs")
void (* const g_pfnVectors[])(void) =
{
(void (*)(void))((uint32_t)&__STACK_TOP),
// The initial stack pointer
ResetISR, // The reset handler
NmiSR, // The NMI handler
FaultISR, // The hard fault handler
IntDefaultHandler, // The MPU fault handler
IntDefaultHandler, // The bus fault handler
IntDefaultHandler, // The usage fault handler
0, // Reserved
0, // Reserved
0, // Reserved
0, // Reserved
IntDefaultHandler, // SVCall handler
IntDefaultHandler, // Debug monitor handler
0, // Reserved
IntDefaultHandler, // The PendSV handler
IntDefaultHandler, // The SysTick handler
IntDefaultHandler, // GPIO Port A
IntDefaultHandler, // GPIO Port B
IntDefaultHandler, // GPIO Port C
IntDefaultHandler, // GPIO Port D
IntDefaultHandler, // GPIO Port E
IntDefaultHandler, // UART0 Rx and Tx
IntDefaultHandler, // UART1 Rx and Tx
IntDefaultHandler, // SSI0 Rx and Tx
IntDefaultHandler, // I2C0 Master and Slave
IntDefaultHandler, // PWM Fault
IntDefaultHandler, // PWM Generator 0
IntDefaultHandler, // PWM Generator 1
IntDefaultHandler, // PWM Generator 2
IntDefaultHandler, // Quadrature Encoder 0
IntDefaultHandler, // ADC Sequence 0
IntDefaultHandler, // ADC Sequence 1
IntDefaultHandler, // ADC Sequence 2
IntDefaultHandler, // ADC Sequence 3
IntDefaultHandler, // Watchdog timer
IntDefaultHandler, // Timer 0 subtimer A
IntDefaultHandler, // Timer 0 subtimer B
IntDefaultHandler, // Timer 1 subtimer A
IntDefaultHandler, // Timer 1 subtimer B
IntDefaultHandler, // Timer 2 subtimer A
IntDefaultHandler, // Timer 2 subtimer B
IntDefaultHandler, // Analog Comparator 0
IntDefaultHandler, // Analog Comparator 1
IntDefaultHandler, // Analog Comparator 2
IntDefaultHandler, // System Control (PLL, OSC, BO)
IntDefaultHandler, // FLASH Control
IntDefaultHandler, // GPIO Port F
IntDefaultHandler, // GPIO Port G
IntDefaultHandler, // GPIO Port H
IntDefaultHandler, // UART2 Rx and Tx
SSI1IntHandler, // SSI1 Rx and Tx
IntDefaultHandler, // Timer 3 subtimer A
IntDefaultHandler, // Timer 3 subtimer B
IntDefaultHandler, // I2C1 Master and Slave
IntDefaultHandler, // CAN0
IntDefaultHandler, // CAN1
IntDefaultHandler, // Ethernet
IntDefaultHandler, // Hibernate
IntDefaultHandler, // USB0
IntDefaultHandler, // PWM Generator 3
IntDefaultHandler, // uDMA Software Transfer
IntDefaultHandler, // uDMA Error
IntDefaultHandler, // ADC1 Sequence 0
IntDefaultHandler, // ADC1 Sequence 1
IntDefaultHandler, // ADC1 Sequence 2
IntDefaultHandler, // ADC1 Sequence 3
IntDefaultHandler, // External Bus Interface 0
IntDefaultHandler, // GPIO Port J
IntDefaultHandler, // GPIO Port K
IntDefaultHandler, // GPIO Port L
IntDefaultHandler, // SSI2 Rx and Tx
IntDefaultHandler, // SSI3 Rx and Tx
IntDefaultHandler, // UART3 Rx and Tx
IntDefaultHandler, // UART4 Rx and Tx
IntDefaultHandler, // UART5 Rx and Tx
IntDefaultHandler, // UART6 Rx and Tx
IntDefaultHandler, // UART7 Rx and Tx
IntDefaultHandler, // I2C2 Master and Slave
IntDefaultHandler, // I2C3 Master and Slave
IntDefaultHandler, // Timer 4 subtimer A
IntDefaultHandler, // Timer 4 subtimer B
IntDefaultHandler, // Timer 5 subtimer A
IntDefaultHandler, // Timer 5 subtimer B
IntDefaultHandler, // FPU
0, // Reserved
0, // Reserved
IntDefaultHandler, // I2C4 Master and Slave
IntDefaultHandler, // I2C5 Master and Slave
IntDefaultHandler, // GPIO Port M
IntDefaultHandler, // GPIO Port N
0, // Reserved
IntDefaultHandler, // Tamper
IntDefaultHandler, // GPIO Port P (Summary or P0)
IntDefaultHandler, // GPIO Port P1
IntDefaultHandler, // GPIO Port P2
IntDefaultHandler, // GPIO Port P3
IntDefaultHandler, // GPIO Port P4
IntDefaultHandler, // GPIO Port P5
IntDefaultHandler, // GPIO Port P6
IntDefaultHandler, // GPIO Port P7
IntDefaultHandler, // GPIO Port Q (Summary or Q0)
IntDefaultHandler, // GPIO Port Q1
IntDefaultHandler, // GPIO Port Q2
IntDefaultHandler, // GPIO Port Q3
IntDefaultHandler, // GPIO Port Q4
IntDefaultHandler, // GPIO Port Q5
IntDefaultHandler, // GPIO Port Q6
IntDefaultHandler, // GPIO Port Q7
IntDefaultHandler, // GPIO Port R
IntDefaultHandler, // GPIO Port S
IntDefaultHandler, // SHA/MD5 0
IntDefaultHandler, // AES 0
IntDefaultHandler, // DES3DES 0
IntDefaultHandler, // LCD Controller 0
IntDefaultHandler, // Timer 6 subtimer A
IntDefaultHandler, // Timer 6 subtimer B
IntDefaultHandler, // Timer 7 subtimer A
IntDefaultHandler, // Timer 7 subtimer B
IntDefaultHandler, // I2C6 Master and Slave
IntDefaultHandler, // I2C7 Master and Slave
IntDefaultHandler, // HIM Scan Matrix Keyboard 0
IntDefaultHandler, // One Wire 0
IntDefaultHandler, // HIM PS/2 0
IntDefaultHandler, // HIM LED Sequencer 0
IntDefaultHandler, // HIM Consumer IR 0
IntDefaultHandler, // I2C8 Master and Slave
IntDefaultHandler, // I2C9 Master and Slave
IntDefaultHandler // GPIO Port T
};
//*****************************************************************************
//
// This is the code that gets called when the processor first starts execution
// following a reset event. Only the absolutely necessary set is performed,
// after which the application supplied entry() routine is called. Any fancy
// actions (such as making decisions based on the reset cause register, and
// resetting the bits in that register) are left solely in the hands of the
// application.
//
//*****************************************************************************
void
ResetISR(void)
{
//
// Jump to the CCS C initialization routine. This will enable the
// floating-point unit as well, so that does not need to be done here.
//
__asm(" .global _c_int00\n"
" b.w _c_int00");
}
//*****************************************************************************
//
// This is the code that gets called when the processor receives a NMI. This
// simply enters an infinite loop, preserving the system state for examination
// by a debugger.
//
//*****************************************************************************
static void
NmiSR(void)
{
//
// Enter an infinite loop.
//
while(1)
{
}
}
//*****************************************************************************
//
// This is the code that gets called when the processor receives a fault
// interrupt. This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void
FaultISR(void)
{
//
// Enter an infinite loop.
//
while(1)
{
}
}
//*****************************************************************************
//
// This is the code that gets called when the processor receives an unexpected
// interrupt. This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void
IntDefaultHandler(void)
{
//
// Go into an infinite loop.
//
while(1)
{
}
}
我已使用 SSI0通道将 ADXL345与 TM4C1294连接。 但是、当我使用 SSI2通道时、我无法获取信号。
下面是 使用 SSI0通道的接口代码
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/ssi.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "driverlib/rom_map.h"
//*******************************************************
// ADXL345 Definitions
//*******************************************************
#define READ 0x8000
//ADXL Register Map
#define DEVID 0x0000 //Device ID Register
#define BW_RATE 0x2C00 //Data rate and power mode control
#define POWER_CTL 0x2D00 //Power Control Register
#define DATA_FORMAT 0x3100 //Data format control
#define DATAX0 0x3200 //X-Axis Data 0
#define DATAX1 0x3300 //X-Axis Data 1
#define DATAY0 0x3400 //Y-Axis Data 0
#define DATAY1 0x3500 //Y-Axis Data 1
#define DATAZ0 0x3600 //Z-Axis Data 0
#define DATAZ1 0x3700 //Z-Axis Data 1
#define MEASURE (1<<3) //Measurement Mode
volatile uint32_t g_breceiveFlag = 0;
uint32_t g_ui32SysClock;
void
SSI1IntHandler(void)
{
uint32_t ui32Status;
//
// Read SSIMIS (SSI Masked Interrupt Status).
//
ui32Status = MAP_SSIIntStatus(SSI1_BASE, true);
//
// Clear the SSI interrupt.
//
MAP_SSIIntClear(SSI1_BASE, ui32Status);
//
// Turn off the RX FIFO interrupt.
//
MAP_SSIIntDisable(SSI1_BASE, SSI_RXFF);
g_breceiveFlag = 1;
}
//*****************************************************************************
//
// This function sets up UART0 to be used for a console to display information
// as the example is running.
//
//*****************************************************************************
void
InitConsole(void)
{
//
// Enable the GPIO Peripheral used by the UART.
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Enable UART0
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
MAP_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0);
//
// Configure GPIO Pins for UART mode.
//
MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Initialize the UART for console I/O.
//
UARTStdioConfig(0, 115200, g_ui32SysClock);
}
//*****************************************************************************
//
// Configure SSI0 in master Freescale (SPI) mode. This example will send out
// 3 bytes of data, then wait for 3 bytes of data to come in. This will all be
// done using the polling method.
//
//*****************************************************************************
int
main(void)
{
uint32_t x_value_raw;
uint32_t y_value_raw;
uint32_t z_value_raw;
uint32_t buffer[10];
uint32_t dataready;
uint32_t pui32DataRx[6];
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_240), 120000000);
InitConsole();
//
// Display the setup on the console.
//
UARTprintf("SSI ->\n");
UARTprintf(" Mode: SPI\n");
UARTprintf(" Data: 16-bit\n\n");
//
// The SSI0 peripheral must be enabled for use.
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
//
// For this example SSI0 is used with PortA[5:2].
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Configure the pin muxing for SSI0 functions on port A2, A3, A4, and A5.
//
MAP_GPIOPinConfigure(GPIO_PA2_SSI0CLK);
MAP_GPIOPinConfigure(GPIO_PA3_SSI0FSS);
MAP_GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);//GPIO_PA4_SSI0RX//tx
MAP_GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);//GPIO_PA5_SSI0TX//rx
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_3);
MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 | GPIO_PIN_2);//
//
// Configure and enable the SSI port for SPI master mode. Use SSI0,
// system clock supply, idle clock level low and active low clock in
// freescale SPI mode, master mode, 1MHz SSI frequency, and 16-bit data.
//
MAP_SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_3, SSI_MODE_MASTER, 1000000, 16);//2,,,,16
// need 16 bit mode - 8 bits for r/w,x,x,ADDR[5:0], then 8 data bits
//
// Enable the SSI0 module.
//
SSIEnable(SSI0_BASE);
while (SSIBusy(SSI0_BASE));
SSIDataPut(SSI0_BASE, 0x80); //Puts a data element into the SSI transmit FIFO
while (SSIBusy(SSI0_BASE));
UARTprintf("ADDRESS:\n",READ);
SSIDataGet(SSI0_BASE, buffer);
while(MAP_SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx[0]))
{
}
SSIDataPut(SSI0_BASE, BW_RATE|0x000A); //Set Output Rate to 100 Hz
while(SSIBusy(SSI0_BASE)){}
UARTprintf("DATA RECEIVED: OUTPUT RATE\n");
SSIDataPut(SSI0_BASE, DATA_FORMAT|0x000A); //set device to +-8g in full resolution mode 3.9mg/lsb accuraccy
while(SSIBusy(SSI0_BASE)){}
UARTprintf("DATA RECEIVED: FORMATTED TO +/- 8g FULLRESMODE 3.9mg/LSB\n");
SSIDataPut(SSI0_BASE, POWER_CTL|MEASURE); //Put the Accelerometer into measurement mode
while(SSIBusy(SSI0_BASE)){}
UARTprintf("DATA RECEIVED: POWER ON\n");
UARTprintf("x\ty\tz\n");
while(1){
SSIDataPut(SSI0_BASE, READ|DATAX0);
SSIDataGet(SSI0_BASE, &pui32DataRx[0]);
while(SSIBusy(SSI0_BASE)){}
SSIDataPut(SSI0_BASE, READ|DATAX1);
SSIDataGet(SSI0_BASE, &pui32DataRx[1]);
while(SSIBusy(SSI0_BASE)){}
x_value_raw = pui32DataRx[1] | (pui32DataRx[0]>>8);
// x_value = x_value_raw*0.00390625; //full resolution mode scaling
SSIDataPut(SSI0_BASE, READ|DATAY0);
SSIDataGet(SSI0_BASE, &pui32DataRx[2]);
while(SSIBusy(SSI0_BASE)){}
SSIDataPut(SSI0_BASE, READ|DATAY1);
SSIDataGet(SSI0_BASE, &pui32DataRx[3]);
while(SSIBusy(SSI0_BASE)){}
y_value_raw = pui32DataRx[3] | (pui32DataRx[2]>>8);
// y_value = y_value_raw*0.00390625; //full resolution mode scaling
SSIDataPut(SSI0_BASE, READ|DATAZ0);
SSIDataGet(SSI0_BASE, &pui32DataRx[4]);
while(SSIBusy(SSI0_BASE)){}
SSIDataPut(SSI0_BASE, READ|DATAZ1);
SSIDataGet(SSI0_BASE, &pui32DataRx[5]);
while(SSIBusy(SSI0_BASE)){}
z_value_raw = pui32DataRx[5] | (pui32DataRx[4]>>8);
// z_value = z_value_raw*0.00390625; //full resolution mode scaling
UARTprintf("x=%d\ty=%d\tz=%d\r\n",x_value_raw,y_value_raw,z_value_raw);
// UARTprintf("\nDATA Received:\n ");
SysCtlDelay(1000);
}
return(0);
}
下面是使用 LA 的 SSI0信号。

下面是 使用 SSI2通道的接口代码
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/ssi.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "driverlib/rom_map.h"
//*******************************************************
// ADXL345 Definitions
//*******************************************************
#define READ 0x8000
////ADXL Register Map
//#define DEVID 0x0000 //Device ID Register
#define BW_RATE 0x2C00 //Data rate and power mode control
#define POWER_CTL 0x2D00 //Power Control Register
#define DATA_FORMAT 0x3100 //Data format control
#define DATAX0 0x3200 //X-Axis Data 0
#define DATAX1 0x3300 //X-Axis Data 1
#define DATAY0 0x3400 //Y-Axis Data 0
#define DATAY1 0x3500 //Y-Axis Data 1
#define DATAZ0 0x3600 //Z-Axis Data 0
#define DATAZ1 0x3700 //Z-Axis Data 1
#define MEASURE (1<<3) //Measurement Mode
volatile uint32_t g_breceiveFlag = 0;
uint32_t g_ui32SysClock;
void
SSI1IntHandler(void)
{
uint32_t ui32Status;
//
// Read SSIMIS (SSI Masked Interrupt Status).
//
ui32Status = MAP_SSIIntStatus(SSI1_BASE, true);
//
// Clear the SSI interrupt.
//
MAP_SSIIntClear(SSI1_BASE, ui32Status);
//
// Turn off the RX FIFO interrupt.
//
MAP_SSIIntDisable(SSI1_BASE, SSI_RXFF);
g_breceiveFlag = 1;
}
//*****************************************************************************
//
// This function sets up UART0 to be used for a console to display information
// as the example is running.
//
//*****************************************************************************
void
InitConsole(void)
{
//
// Enable the GPIO Peripheral used by the UART.
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Enable UART0
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
MAP_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0);
//
// Configure GPIO Pins for UART mode.
//
MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Initialize the UART for console I/O.
//
UARTStdioConfig(0, 115200, g_ui32SysClock);
}
//*****************************************************************************
//
// Configure SSI0 in master Freescale (SPI) mode. This example will send out
// 3 bytes of data, then wait for 3 bytes of data to come in. This will all be
// done using the polling method.
//
//*****************************************************************************
int
main(void)
{
uint32_t x_value_raw;
uint32_t y_value_raw;
uint32_t z_value_raw;
uint32_t buffer[10];
uint32_t dataready;
uint32_t pui32DataRx[6];
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_240), 120000000);
InitConsole();
//
// Display the setup on the console.
//
UARTprintf("SSI ->\n");
UARTprintf(" Mode: SPI\n");
UARTprintf(" Data: 16-bit\n\n");
//
// The SSI0 peripheral must be enabled for use.
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
//
// For this example SSI0 is used with PortA[5:2].
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
//
// Configure the pin muxing for SSI0 functions on port A2, A3, A4, and A5.
//
MAP_GPIOPinConfigure(GPIO_PD3_SSI2CLK);//GPIO_PA2_SSI0CLK
MAP_GPIOPinConfigure(GPIO_PD2_SSI2FSS);//GPIO_PA3_SSI0FSS
MAP_GPIOPinConfigure(GPIO_PD1_SSI2XDAT0);//GPIO_PA5_SSI0XDAT1//GPIO_PA4_SSI0RX//tx
MAP_GPIOPinConfigure(GPIO_PD0_SSI2XDAT1);//GPIO_PA4_SSI0XDAT0//GPIO_PA5_SSI0TX//rx
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_3);
MAP_GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0);//
//
// Configure and enable the SSI port for SPI master mode. Use SSI0,
// system clock supply, idle clock level low and active low clock in
// freescale SPI mode, master mode, 1MHz SSI frequency, and 16-bit data.
//
MAP_SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_3, SSI_MODE_MASTER, 1000000, 16);//2,,,,16
// need 16 bit mode - 8 bits for r/w,x,x,ADDR[5:0], then 8 data bits
//
// Enable the SSI0 module.
//
SSIEnable(SSI2_BASE);
while (SSIBusy(SSI2_BASE));
SSIDataPut(SSI2_BASE, 0x80); //Puts a data element into the SSI transmit FIFO
while (SSIBusy(SSI2_BASE));
UARTprintf("ADDRESS:\n",READ);
SSIDataGet(SSI2_BASE, buffer);
while(MAP_SSIDataGetNonBlocking(SSI2_BASE, &pui32DataRx[0]))
{
}
SSIDataPut(SSI2_BASE, BW_RATE|0x000A); //Set Output Rate to 100 Hz
while(SSIBusy(SSI2_BASE)){}
UARTprintf("DATA RECEIVED: OUTPUT RATE\n");
SSIDataPut(SSI2_BASE, DATA_FORMAT|0x000A); //set device to +-8g in full resolution mode 3.9mg/lsb accuraccy
while(SSIBusy(SSI2_BASE)){}
UARTprintf("DATA RECEIVED: FORMATTED TO +/- 8g FULLRESMODE 3.9mg/LSB\n");
SSIDataPut(SSI2_BASE, POWER_CTL|MEASURE); //Put the Accelerometer into measurement mode
while(SSIBusy(SSI2_BASE)){}
UARTprintf("DATA RECEIVED: POWER ON\n");
UARTprintf("x\ty\tz\n");
while(1){
SSIDataPut(SSI2_BASE, READ|DATAX0);
SSIDataGet(SSI2_BASE, &pui32DataRx[0]);
while(SSIBusy(SSI2_BASE)){}
SSIDataPut(SSI2_BASE, READ|DATAX1);
SSIDataGet(SSI2_BASE, &pui32DataRx[1]);
while(SSIBusy(SSI2_BASE)){}
x_value_raw = pui32DataRx[1] | (pui32DataRx[0]>>8);
// x_value = x_value_raw*0.00390625; //full resolution mode scaling
SSIDataPut(SSI2_BASE, READ|DATAY0);
SSIDataGet(SSI2_BASE, &pui32DataRx[2]);
while(SSIBusy(SSI2_BASE)){}
SSIDataPut(SSI2_BASE, READ|DATAY1);
SSIDataGet(SSI2_BASE, &pui32DataRx[3]);
while(SSIBusy(SSI2_BASE)){}
y_value_raw = pui32DataRx[3] | (pui32DataRx[2]>>8);
// y_value = y_value_raw*0.00390625; //full resolution mode scaling
SSIDataPut(SSI2_BASE, READ|DATAZ0);
SSIDataGet(SSI2_BASE, &pui32DataRx[4]);
while(SSIBusy(SSI2_BASE)){}
SSIDataPut(SSI2_BASE, READ|DATAZ1);
SSIDataGet(SSI2_BASE, &pui32DataRx[5]);
while(SSIBusy(SSI0_BASE)){}
z_value_raw = pui32DataRx[5] | (pui32DataRx[4]>>8);
// z_value = z_value_raw*0.00390625; //full resolution mode scaling
// UARTprintf("%d\t%d\t%d\r",x_value_raw,y_value_raw,z_value_raw);
// UARTprintf("\nDATA Received: ");
UARTprintf("x=%d\ty=%d\tz=%d\r\n",x_value_raw,y_value_raw,z_value_raw);
SysCtlDelay(1000);
}
return(0);
}
它们不是 SSI2通道中的信号、 如 LA 中所示

我已经进行了必要的更改以使用 SSI2通道、但无法获取任何信号。 我 的 SSI2 通道代码中有什么错误? 您能就此提出任何建议吗?
谢谢你
我在您的 SSI2代码中发现了两个错误。 在第148行、您可以致电:
MAP_SSIConfigSetExpClk (SSI2_base、SysCtlClockGet ()、SSI_FRF_MOTO_MOTO_MODE_3、SSI_MODE_MASTER、1000000、 16)。
您不能使用 SysCtlClockGet ()、因为这是针对 TM4C123 MCU 的。 您需要按如下方式使用。
MAP_SSIConfigSetExpClk (SSI2_base、g_ui32SysClock、SSI_FRF_MOTO_MODE_3、SSI_MODE_MASTER、1000000、 16)。
第二个错误是第208行。 您在第208行有以下行。 您仍在检查 SSI0、而不是 SSI2。 由于您从未在 开始时初始化 SSI0、这条线实际上会给 CPU 生成一个故障。
while (SSIBusy (SSI0_BASE)){}。