《线程》中讨论的其他部件: MSP430G2553, ENERGIA
我一直在使用编程器和调试模块与 MSP430FR2676合作,并采用典型的金刚石阵列8x8共电容阵列设计。 我想知道如何获得该阵列中每个传感器的过滤计数,并不断通过 UART 传输这些信息。 我一直关注 MSP430FR2676后向频道 UART 演示,该演示在迷人的设计工作室中找到。 我打开了这个项目并将它加载到我的主板上,我在 CCS 中打开了终端,希望看到这些信息被发送出去,但无法完成这项工作。 根据我收集的数据,这个特定示例仅假定在按下按钮时输出信息,并且只输出一个特定的过滤按钮对终端的计数(尽管尚未看到这种情况有效)。 我一直在使用 此 http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSP430Ware/3_70_00_05/exports/MSP430Ware_3_70_00_05/captivate/docs/api_guide/FR2633/html/group__CAPT__Buttons.html 作为参考,我看到 Capt_Buttons 下列出的三个函数似乎仅支持查找正在按下的主按钮,不允许我访问所有过滤的按钮计数? 是否有任何示例代码可用于此类事物的进一步示例,或任何可能有帮助的资源? 根据我目前的理解,我在 Captivate Design Studio 中创建了我的项目,调整我的传感器,然后为 CCS 生成源代码,然后将有关 UART 通信的代码添加到此代码中,并将其上传到主板。 我在这个迷人的设计工作室里附上了我当前项目的一些图像(我成功地调谐了我的传感器)。 我在使用“嵌入式系统”方面的唯一经验是使用 Energia 对 MSP430G2553进行编程,我认为这种编程不支持被迷住的设备,CCS 对我来说相当抽象。 这些是我迄今为止一直在使用的现有资源:
https://www.ti.com/lit/ug/slau445i/slau445i.pdf
以下是德州仪器(TI)在演示中提供的代码示例(我重点关注的部分):
//############################################################################# // //! \file Backchannel_UART_demo.c // // Group: MSP // Target Devices: MSP430FR2633 // // (C) Copyright 2018, Texas Instruments, Inc. //############################################################################# // TI Release: 1.83.00.05 // Release Date: May 15, 2020 //############################################################################# //***************************************************************************** // Includes //***************************************************************************** #include "demo.h" //***************************************************************************** // Definitions //***************************************************************************** //***************************************************************************** // Global Variables //***************************************************************************** //***************************************************************************** // Function Prototypes //***************************************************************************** //***************************************************************************** // Function Implementations //***************************************************************************** //callback function for keypad buttons void keypad_callback(tSensor* pSensor){ //trigger once when the button is touched if(((pSensor->bSensorTouch)) && (!(pSensor->bSensorPrevTouch))){ //decode the dominant button number uint8_t myButtonNumber = CAPT_getDominantButton(pSensor); uint8_t loopCounter = 0; uint8_t cycleCounter = 0; uint8_t elementCounter = 0; uint8_t myCycle; uint8_t myElement; //go through each cycle pointer, and within it each element pointer to find element that corresponds to the dominant button for(cycleCounter = 0; cycleCounter < pSensor->ui8NrOfCycles; ++cycleCounter){ for(elementCounter = 0; elementCounter < pSensor->pCycle[cycleCounter]->ui8NrOfElements; ++elementCounter){ //get the cycle and element numbers from the dominant button if(loopCounter == myButtonNumber){ myCycle = cycleCounter; myElement = elementCounter; } loopCounter++; } } //placeholder for output data, must be static to ensure that it is available & unchanged across function calls static uint8_t str[100]; //access the element's raw count //CAPT_getDominantButton() returns 0x00 for button #1, 0x01 for button #2... etc uint16_t rawCount = pSensor->pCycle[myCycle]->pElements[myElement]->pRawCount[0]; //extract the filtered count, NOTE this truncates to the nearest natural number uint16_t filteredCount = pSensor->pCycle[myCycle]->pElements[myElement]->filterCount.ui16Natural ; //get the length of the output string, insert int data into output string uint8_t str_length = sprintf((char*)str, "Button Pressed: %d\tRaw Count: %d\tFiltered Count: %d\n\r", myButtonNumber + 1, rawCount, filteredCount); //transmit data UART_transmitBuffer(str, str_length); } } //Sets all the parameters for UART transmission const tUARTPort UARTPort = { //does not receive messages, so no callback needed .pbReceiveCallback = NULL, //does not receive messages, so no callback needed .pbErrorCallback = 0, //choose clock source .peripheralParameters.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK, //clockPrescalar is UCBRx = int(N / 16), where N = clock_frequency / baud_rate //int(N / 16) = int(2000000 / 9600 / 16) = int(13.02) = 13; .peripheralParameters.clockPrescalar = SMCLK_FREQ_MHZ * 1000000 / 9600 / 16, //controls UCBRF bits for oversampling mode //UCBRF = int(((N/16) - int(N/16)) * 16) = int(((208.3333/16) - int(208.3333/16)) * 16) = int(0.3333) = 0 .peripheralParameters.firstModReg = 0, //consult table 22-4 in the user's guide to find the register value corresponding to UCBRF number //fraction portion of N = 0.3333 //in the table, 0.3333 <---> 0x49 .peripheralParameters.secondModReg = 0x49, //controls parity bit - NOTE the eZ-FET does not support a parity bit .peripheralParameters.parity = EUSCI_A_UART_NO_PARITY, //least or most significant bit first .peripheralParameters.msborLsbFirst = EUSCI_A_UART_LSB_FIRST, //select either one or two stop bits .peripheralParameters.numberofStopBits = EUSCI_A_UART_ONE_STOP_BIT, //select whether to use multiprocessor/autobaud modes .peripheralParameters.uartMode = EUSCI_A_UART_MODE, //selects oversampling vs low-freq baud rate modes .peripheralParameters.overSampling = EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION };