贴一个自己常用的代码,串口收一个16进制数然后回送,感觉一般实验室的控制系统用这个就足够了。
#include "driverlib.h"
#include "device.h"
#ifdef _FLASH
// These are defined by the linker (see device linker command file)
extern uint16_t RamfuncsLoadStart;
extern uint16_t RamfuncsLoadSize;
extern uint16_t RamfuncsRunStart;
#endif
uint16_t msg=0; // 串口接收到的数据
__interrupt void sciaRxISR(void);
void mySCIAconfig(void); //GPIO 28 29 SCIARX中断 波特率115200 接收一位16进制并回送
void main(void)
{
// Configure PLL, disable WD, enable peripheral clocks.
Device_init();
// Disable pin locks and enable internal pullups.
Device_initGPIO();
// Disable global interrupts.
DINT;
// Initialize interrupt controller and vector table.
Interrupt_initModule();
Interrupt_initVectorTable();
IER = 0x0000;
IFR = 0x0000;
mySCIAconfig();
// Enable global interrupts.
EINT;
for(;;)
{
}
}
void mySCIAconfig(void)
{
/*
SCIA配置函数,GPIO28为Rx,GPIO29为Tx
波特率115200,映射并启用SCIA_RX中断
*/
// GPIO28 is the SCI Rx pin.
GPIO_setMasterCore(DEVICE_GPIO_PIN_SCIRXDA, GPIO_CORE_CPU1);
GPIO_setPinConfig(DEVICE_GPIO_CFG_SCIRXDA);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(DEVICE_GPIO_PIN_SCIRXDA, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_QUAL_ASYNC);
// GPIO29 is the SCI Tx pin.
GPIO_setMasterCore(DEVICE_GPIO_PIN_SCITXDA, GPIO_CORE_CPU1);
GPIO_setPinConfig(DEVICE_GPIO_CFG_SCITXDA);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(DEVICE_GPIO_PIN_SCITXDA, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_QUAL_ASYNC);
// Map the ISR to the wake interrupt.
Interrupt_register(INT_SCIA_RX, sciaRxISR);
// Initialize SCIA and its FIFO.
SCI_performSoftwareReset(SCIA_BASE);
// 波特率115200 8位数据 1位停止 无校验位
SCI_setConfig(SCIA_BASE, 25000000, 115200, (SCI_CONFIG_WLEN_8 |
SCI_CONFIG_STOP_ONE |
SCI_CONFIG_PAR_NONE));
SCI_resetChannels(SCIA_BASE);
SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_RXRDY_BRKDT);
SCI_enableModule(SCIA_BASE);
SCI_performSoftwareReset(SCIA_BASE);
// Enable the TXRDY and RXRDY interrupts.
SCI_enableInterrupt(SCIA_BASE, SCI_INT_RXRDY_BRKDT);
// Clear the SCI interrupts before enabling them.
SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_RXRDY_BRKDT);
// Enable the interrupts in the PIE: Group 9 interrupts 1 & 2.
Interrupt_enable(INT_SCIA_RX);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}
// sciaRxISR - Read the character from the RXBUF and echo it back.
__interrupt void sciaRxISR(void)
{
uint16_t receivedChar;
// Read a character from the RXBUF.
receivedChar = SCI_readCharBlockingNonFIFO(SCIA_BASE);
msg=receivedChar; // 更新全局变量
// Echo back the character.
SCI_writeCharBlockingNonFIFO(SCIA_BASE, receivedChar);
// Acknowledge the PIE interrupt.
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}
此测试通过SCI-A端口接收和回送数据。串口的设置为:
波特率:9600
数据位:8
校验:无
停止位:1
程序将打印出一个问候语,然后要求您输入一个字符,它将回显到终端。
外部接线:
GPIO28是 SCI_A-RXD 需要连接PC-TX;
GPIO29是 SCI_A-TXD 需要连接PC-RX。
此测试使用中断通过SCI-A端口接收和回送数据。
这是一个比较贴近实际应用的示例。
外部配置与上例相同。
#include "driverlib.h"
#include "device.h"
#ifdef _FLASH
// These are defined by the linker (see device linker command file)
extern uint16_t RamfuncsLoadStart;
extern uint16_t RamfuncsLoadSize;
extern uint16_t RamfuncsRunStart;
#endif
//
// Defines
//
// Define AUTOBAUD to use the autobaud lock feature
//#define AUTOBAUD
//
// Globals
//
uint16_t counter = 0;
unsigned char *msg;
//
// Function Prototypes
//
__interrupt void sciaTxISR(void);
__interrupt void sciaRxISR(void);
//
// Main
//
void main(void)
{
//
// Configure PLL, disable WD, enable peripheral clocks.
//
Device_init();
//
// Disable pin locks and enable internal pullups.
//
Device_initGPIO();
//
// GPIO28 is the SCI Rx pin.
//
GPIO_setMasterCore(DEVICE_GPIO_PIN_SCIRXDA, GPIO_CORE_CPU1);
GPIO_setPinConfig(DEVICE_GPIO_CFG_SCIRXDA);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(DEVICE_GPIO_PIN_SCIRXDA, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_QUAL_ASYNC);
//
// GPIO29 is the SCI Tx pin.
//
GPIO_setMasterCore(DEVICE_GPIO_PIN_SCITXDA, GPIO_CORE_CPU1);
GPIO_setPinConfig(DEVICE_GPIO_CFG_SCITXDA);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(DEVICE_GPIO_PIN_SCITXDA, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_QUAL_ASYNC);
//
// Disable global interrupts.
//
DINT;
//
// Initialize interrupt controller and vector table.
//
Interrupt_initModule();
Interrupt_initVectorTable();
IER = 0x0000;
IFR = 0x0000;
//
// Map the ISR to the wake interrupt.
//
Interrupt_register(INT_SCIA_TX, sciaTxISR);
Interrupt_register(INT_SCIA_RX, sciaRxISR);
//
// Initialize SCIA and its FIFO.
//
SCI_performSoftwareReset(SCIA_BASE);
//
// Configure SCIA for echoback.
//
SCI_setConfig(SCIA_BASE, 25000000, 9600, (SCI_CONFIG_WLEN_8 |
SCI_CONFIG_STOP_ONE |
SCI_CONFIG_PAR_NONE));
SCI_resetChannels(SCIA_BASE);
SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXRDY | SCI_INT_RXRDY_BRKDT);
SCI_enableModule(SCIA_BASE);
SCI_performSoftwareReset(SCIA_BASE);
//
// Enable the TXRDY and RXRDY interrupts.
//
SCI_enableInterrupt(SCIA_BASE, SCI_INT_TXRDY | SCI_INT_RXRDY_BRKDT);
#ifdef AUTOBAUD
//
// Perform an autobaud lock.
// SCI expects an 'a' or 'A' to lock the baud rate.
//
SCI_lockAutobaud(SCIA_BASE);
#endif
//
// Send starting message.
//
msg = "\r\n\n\nHello World!\0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 17);
msg = "\r\nYou will enter a character, and the DSP will echo it back!\n\0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 62);
//
// Clear the SCI interrupts before enabling them.
//
SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXRDY | SCI_INT_RXRDY_BRKDT);
//
// Enable the interrupts in the PIE: Group 9 interrupts 1 & 2.
//
Interrupt_enable(INT_SCIA_RX);
Interrupt_enable(INT_SCIA_TX);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
//
// Enable global interrupts.
//
EINT;
for(;;)
{
}
}
//
// sciaTxISR - Disable the TXRDY interrupt and print message asking
// for a character.
//
__interrupt void
sciaTxISR(void)
{
//
// Disable the TXRDY interrupt.
//
SCI_disableInterrupt(SCIA_BASE, SCI_INT_TXRDY);
msg = "\r\nEnter a character: \0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 22);
//
// Ackowledge the PIE interrupt.
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}
//
// sciaRxISR - Read the character from the RXBUF and echo it back.
//
__interrupt void
sciaRxISR(void)
{
uint16_t receivedChar;
//
// Enable the TXRDY interrupt again.
//
SCI_enableInterrupt(SCIA_BASE, SCI_INT_TXRDY);
//
// Read a character from the RXBUF.
//
receivedChar = SCI_readCharBlockingNonFIFO(SCIA_BASE);
//
// Echo back the character.
//
msg = " You sent: \0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 13);
SCI_writeCharBlockingNonFIFO(SCIA_BASE, receivedChar);
//
// Acknowledge the PIE interrupt.
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
counter++;
}
//
// End of File
//
此测试通过SCI-A端口接收和回送数据,一次中断传送两个字符。在FIFO状态级别为2或更高之后触发Rx中断。一旦RXFIFO中有两个字符,SCI Rx ISR将被触发,并从FIFO中读取两个字符并将其写入传输缓冲区。然后,SCI Tx ISR将再次被触发,以从终端请求更多数据。
外部配置与上例相同。
文章浏览阅读1.2k次。import java.util.LinkedList;public class ThreadPoolUtil extends ThreadGroup{ private static final ThreadPoolUtil instance = new ThreadPoolUtil(5); private boolean isClosed = false_java threadpoolutil
文章浏览阅读6.5k次。在使用Spring AOP做切面时,对方法增强处理,经常需要获取方法参数。需要使用JoinPoint作为第一个参数,因为当该代理方法执行时,JoinPoint代表了织..._spring 切面中获取参数的工具类
文章浏览阅读964次,点赞5次,收藏27次。CMMI全称是Capability Maturity Model Integration,是能力成熟度集成模型,是由美国国防部与卡内基-梅隆大学和美国国防工业协会共同开发和研制的。CMMI分为5个等级:CMMI-1(初始级):其实就是0级,代表软件过程是无序的,对过程几乎没有定义。CMMI-2(可管理级):建立了基本的项目管理过程来跟踪费用、进度和功能特性。制定了必要的过程纪律,能重复早先类似应用项目取得的成功经验。CMMI-3(已定义级):已将软件管理和工程两方面的过程文档化、标准化,并综
文章浏览阅读1.2k次,点赞3次,收藏9次。工具:Quartus、Modelsim。内容:用Verilog语言编写4位二进制计数器,并仿真、下载、通过逻辑分析仪在线调试。_verilog 4位计数器
文章浏览阅读412次。在安装好Anaconda环境,并配好环境的前提下,安装tensorflow-gpu 安装tensorflow-gpuconda install -c conda-forge tensorflow-gpu或者安装keras-gpu keras-gpu自带Nvidia Gpu和tensorflow安装配置属性,可根据系统自行检测安装环境及工具包conda install keras-g..._ubuntu1604 ros环境下dconda 安装tensorflow-gpu
文章浏览阅读1.2k次。在求解机器学习算法的模型参数,即无约束优化问题时,梯度下降(Gradient Descent)是最常采用的方法之一,另一种常用的方法是最小二乘法。这里就对梯度下降法做一个完整的总结。1.梯度在微积分里面,对多元函数的参数求∂偏导数,把求得的各个参数的偏导数以向量的形式写出来,就是梯度。比如函数f(x,y), 分别对x,y求偏导数,求得的梯度向量就是(∂f/∂x, ∂f/∂y)T,简_机器学习算法中哪些用了梯度下降法
文章浏览阅读288次。First and foremost, you need to install dsh. The downloads page for the project is a nightmare (http://www.netfort.gr.jp/~dancer/software/downloads/list.cgi), but you basically want the latest version..._linux dsh
文章浏览阅读1.2k次。百度智能云正携手能源行业合作伙伴,全力建设新基建智慧能源。9月25日,百度智能云智慧能源行业峰会在广州举行,详解能源AI中台、知识中台,全新升级的全息可视化智慧巡检,从视频云、边云融合、..._王磊 百度智慧能源行业
文章浏览阅读166次。我猜使用Jython,你可以用Python做任何你可以在Java中做的事情.相反,Python具有PyPy编译器,这是非常酷的 – 具有多个备份的虚拟机(Java Runtime,LLVM,.net和Python IIRC),多个垃圾收集器,多个实现(Stackless)等.我知道Java具有虚拟机的大选择,但PyPy的增长是惊人的,因为它是用RPython编写的 – 这是一个相当有成效的语言.此..._pathen能作java
文章浏览阅读7.1k次,点赞2次,收藏14次。尝试过很多方法来部署OpenStack,失败过很多次,最终找到一种比较方便快捷的方法,熟练的话可以在三个小时内部署成功!现记录一下部署过程,如果还没有思路的同学,相信按照这篇博客能很快部署成功! 1. 安装如下软件,下载资源 安装VirtualBox、Xshell、Xftp、花生壳 下载MirantisOpenStack-5.0.iso、CentOS-7-x86_64-GenericClo..._mirantisopenstack-5.0.iso
文章浏览阅读960次。Spring其中一个核心 AOP(Aspect Oriented Programming)面向切面编程,通过切面注入的方式对目标方法增强。 ..._切点方法增加注解
文章浏览阅读1.2k次。<!--html {font-family:Times,serif; font-size:12pt}.title {text-align:center}.todo {color:red}.done {color:green}.tag {background-color:#add8e6; font-weight:normal}.timestamp