Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- SimonNOWAK
- Date:
- 2017-04-05
- Revision:
- 0:25823c5e440a
- Child:
- 1:2b6896966307
File content as of revision 0:25823c5e440a:
#include "mbed.h"
void usartSetup (void) {
RCC->IOPENR |= RCC_IOPENR_IOPAEN;
GPIOA->ODR |= GPIO_ODR_OD9;
RCC->APB2ENR |= RCC_APB2ENR_USART1EN; // enable clock for USART1
USART1->BRR = 160000 / 96; // set baudrate
USART1->CR1 |= (USART_CR1_RE | USART_CR1_TE); // RX, TX enable
USART1->CR1 |= USART_CR1_UE; // USART enable
}
void SendChar(){
while (!(USART1->ISR & (USART1->ISR | USART_ISR_TXE)));
char stringtosend[4];
stringtosend[0] = 'T';
stringtosend[1] = 'e';
stringtosend[2] = 'x';
stringtosend[3] = 't';
for(int send = 0; send < 4; send++){
USART1->TDR = stringtosend[send];
}
}
int main() {
usartSetup();
SendChar();
}