- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对 ARM 很陌生,正在尝试配置 UART。我使用的主板是STM32F3 发现。目前我只尝试从 USART1 的 PA9 上获取 tx 信号,rx 的中断例程尚未编写。在我看来,当我使用示波器时,我应该在 PA9 上看到一个信号,但 PIN 具有来自上拉的恒定 3V 电压。我使用引用手册进行配置并按照描述初始化所有寄存器。你看到什么错误了吗?到目前为止我的代码:
/*----------------------------------------------------------------------------
* CMSIS-RTOS 'main' function template
*---------------------------------------------------------------------------*/
#define osObjectsPublic // define objects in main module
#include "osObjects.h" // RTOS object definitions
#include "stm32f3xx.h" // Device header
/*
* Defines
*/
#define SYS_FREQUENCY 8000000L //8Mhz
/*
* Global Variables
*/
long baudrate=9600;
//----------------------------------------------------------------------------------------------------
void initGPIO() {
// initialize peripherals here
//Activate red LED Port
RCC->AHBENR |= RCC_AHBENR_GPIOEEN; //enable PORTE clock
GPIOE->MODER |= GPIO_MODER_MODER9_0; //PORTE9 (LED red) is output
}
void initUSART(long baudrate) {
long baudratio=SYS_FREQUENCY/baudrate;
//Clock
RCC->AHBENR |= RCC_AHBENR_GPIOAEN; //enable PORTA clock
RCC->APB2ENR |= RCC_APB2ENR_USART1EN | RCC_APB2ENR_SYSCFGEN; //ENABLE USART1 Clock
//AF
GPIOA->AFR[1] = 0;
GPIOA->AFR[0] = GPIO_AFRL_AFRL7 & (7U<<8); //AF7 Configuration
//TX (PA9)
GPIOA->MODER |= GPIO_MODER_MODER9_1 ; //Alternating function, for TX (PA9)
GPIOA->OTYPER = 0; //Push-Pull
GPIOA->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR9_0 | GPIO_OSPEEDER_OSPEEDR9_1; //Fast Speed
GPIOA->PUPDR |= GPIO_PUPDR_PUPDR9_0; //Pull-Up
//RX (PA)
GPIOA->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR10_0 | GPIO_OSPEEDER_OSPEEDR10_1; //Fast Speed
//USART
USART1->CR1 =0; //Reset
USART1->CR2 =0; //Reset
USART1->CR3 =0; //Reset
USART1->BRR = baudratio & 0xFFFF; //set Baudrate to 9600
USART1->CR1 |= (USART_CR1_TE |USART_CR1_TXEIE | USART_CR1_RXNEIE| USART_CR1_RE); //TX, RX Enable, Interrupts Enable
USART1->CR1 |= USART_CR1_UE; //Enable USART
}
void sendChar(char c) {
while(USART_ISR_TXE==1); //Data transfered to shift register
USART1->TDR = (c & 0xFF);
GPIOE->BSRRL = GPIO_BSRR_BS_9; //LED on -> BSRRL is Bit Set Reset Register -> write 1 -> high
osDelay(50);
GPIOE->BSRRH = GPIO_BSRR_BS_9 ; //LED off
osDelay(50);
}
void sendXThread(void const *argument) {
while(1) {
osDelay(150);
sendChar('X');
}
}
osThreadDef(sendXThread,osPriorityNormal,1,0);
//----------------------------------------------------------------------------------------------------
int main (void) {
osKernelInitialize (); // initialize CMSIS-RTOS
//----------------------------------------------------------------------------------------------------
initGPIO();
initUSART(baudrate);
//----------------------------------------------------------------------------------------------------
// create 'thread' functions that start executing,
// example: tid_name = osThreadCreate (osThread(name), NULL);
osThreadCreate(osThread (sendXThread),NULL);
osKernelStart (); // start thread execution
}
最佳答案
while(USART_ISR_TXE==1);
USART_ISR_TXE
是一个已定义的常量 ( #define USART_ISR_TXE (1 << 7)
),它与 ISR
没有任何共同点自行注册。您只是将 2^7 与 1 进行比较。
关于c - STM32F303 USART配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39642198/
我正在对 JVM 上的 STM 技术进行一些研究。阅读了一些文档后,我对 Multiverse 的实现有些困惑。 根据 the Multiverse FAQ , Multiverse 不支持检测。然而
我想知道 Clojure 怎么可能已经实现了软件事务内存并且没有发现任何问题,而微软没有完成它的 C# 工作并注意到一些问题使得实现这里描述的 STM 不切实际: http://www.bluebyt
最后,我有以下设置 C:>哪里玩 C:\apps\play-2.2.0\play C:\apps\play-2.2.0\play.bat C:> 哪里 scala C:\apps\scala\bin\
我试图找出 Clojure 所称的 STM 与 Haskell 中实现的 STM 之间的区别。撇开实际的语言语义差异不谈,正如 Rich Hickey 在他的演讲中所说,Clojure 的 STM 实
阅读 Bartosz Milewski 的精彩作品 blog post在 STM 上,我很兴奋地阅读了以下内容: But take into account an important fact: ST
大家好, 在某些时候,我认为这些 stm 实现(我使用过一点点的多元宇宙......),被过度宣传了。因为在某些时候他们使用 CAS 来为他们提供操作的原子性。如果我直接使用 CAS 而不是使用这些实
haskell 的 stm 库中有一个函数,其类型签名如下: alwaysSucceeds :: STM a -> STM () 根据我对 Haskell 中 STM 的了解,在执行 STM 计算时,
在 Clojure 中,我们使用 STM 来实现并发。 我的问题是STM使用数据的时间点值,这是否会带来歧义? 我们如何知道访问了什么值? 最佳答案 Clojure 中的 STM 提供了(通过 ref
我需要有关用作原子更改日志的数据结构的建议。 我正在尝试实现以下算法。有流量传入更改更新内存中的映射。在类似 Haskell 的伪代码中它是 update :: DataSet -> Some
我正在尝试对这两个(软件事务内存和原子操作,我想两者不一样)进行一些基准测试,尽管我没有使用STM做太多事情(它似乎很难使用),但我成功地尝试了对基准测试进行计数,即所有线程将共享计数器递增 5000
我能够使用 STM 初始化状态并将其打印出来: module Main where import Control.Concurrent.STM data State = State {name ::
我读过两个关于 STM 如何实现的完全不同的描述。也许两者都是正确的,或者一个是错误的,我希望有人能阐明这一点。 Take 1(维基百科):允许所有线程修改共享内存,但事务中的每次读写都会被记录下来。
我知道将具有副作用的函数放在 STM 事务中通常是不好的做法,因为它们可能会被重试和调用多次。 然而,在我看来,您可以使用代理来确保只有在事务成功完成后才会执行副作用。 例如 (dosync //
我正在编写一个程序,其中大量代理监听事件并对其使用react。由于Control.Concurrent.Chan.dupChan已弃用我决定使用 TChan 的广告。 TChan 的表现比我预想的差很
我正在研究 Clojure 中的并发编程。 http://clojure.org/concurrent_programming 我了解到atom、ref和agent形式是用来维护程序状态的。 仅ref
你好,我正在阅读《clojure 的乐趣》这本书,在关于 STM 的部分中,他们有一个 2 个事务的图像,其中 A 最初从引用中检索与 B 相同的值,然后事务 A 和 B 都进行计算但 A 首先完成并
我熟悉Database transactions ,并花费了大量的时间调整isolation levels 。我从未在代码中实现过自己的事务模型。 我已通读 the source code对于 Clo
我有一个事务由于某种原因无限期失败,我想在内部使用跟踪指令。例如,要在执行此片段中的事务之前打印 MVar 的状态: data_out do putTMVar
当我们运行 STM 表达式时,它命中了 retry,线程被阻塞,如果条目被修改,事务将再次运行。 但我想知道: 如果我们读取一个 STM 变量,但在导致重试的特定分支中实际未使用该变量,更新它是否会尝
我正在研究 Clojure 中的并发编程。 http://clojure.org/concurrent_programming 我了解到atom、ref 和agent 表单用于维护程序状态。 只有 r
我是一名优秀的程序员,十分优秀!