일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- 전기차
- dynamodb
- esp8266
- AWS
- 라즈베리파이
- IOT Core
- 충전기
- 완속충전기
- 전기차충전기
- 서버리스
- homeassistant
- thread
- 전기차충전
- 안드로이드
- 에버온
- 홈어시스턴트
- raspberry
- YMODEM
- flask
- STM32
- 플라스크
- 보안
- lambda
- OCPP
- 파이썬
- 디자인패턴
- 펌웨어
- Android
- everon
- 급속충전기
Archives
- Today
- Total
Louie NRT Story
[Firmware] M058 - UART 본문
반응형
[설명]
- pin3.0과 pin3.1을 UART로 사용한다고 설정함
[기본코드]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include <stdio.h>
#include "M051Series.h"
#define PLL_CLOCK 50000000
void SYS_Init(void)
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init System Clock */
/*---------------------------------------------------------------------------------------------------------*/
/* Enable Internal RC clock */
CLK_EnableXtalRC(CLK_PWRCON_OSC22M_EN_Msk);
/* Waiting for Internal RC clock ready */
CLK_WaitClockReady(CLK_CLKSTATUS_OSC22M_STB_Msk);
/* Switch HCLK clock source to Internal RC and HCLK source divide 1 */
CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HIRC, CLK_CLKDIV_HCLK(1));
/* Set core clock as PLL_CLOCK from PLL */
CLK_SetCoreClock(PLL_CLOCK);
/* Enable UART module clock */
CLK_EnableModuleClock(UART0_MODULE);
/* Select UART module clock source */
CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART_S_HXT, CLK_CLKDIV_UART(1));
CLK->CLKSEL1 |= CLK_CLKSEL1_UART_S_PLL;
/*---------------------------------------------------------------------------------------------------------*/
/* Init I/O Multi-function */
/*---------------------------------------------------------------------------------------------------------*/
/* Set P3 multi-function pins for UART0 RXD and TXD */
SYS->P3_MFP &= ~(SYS_MFP_P30_Msk | SYS_MFP_P31_Msk);
SYS->P3_MFP |= (SYS_MFP_P30_RXD0 | SYS_MFP_P31_TXD0);
}
void UART0_Init()
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init UART */
/*---------------------------------------------------------------------------------------------------------*/
/* Reset UART0 */
SYS_ResetModule(UART0_RST);
/* Configure UART0 and set UART0 Baudrate */
UART_Open(UART0, 115200);
}
int main(void)
{
/* Unlock protected registers */
SYS_UnlockReg();
/* Init System, peripheral clock and multi-function I/O */
SYS_Init();
/* Lock protected registers */
SYS_LockReg();
/* Init UART0 for printf and testing */
UART0_Init();
while(1)
{
printf("\n\nCPU @ %dHz\n", SystemCoreClock);
printf("\n\nUART Sample Program\n");
}
}
|
반응형
'스마트홈' 카테고리의 다른 글
[Firmware] M058 - Timer Interrupt (0) | 2019.05.03 |
---|---|
[Firmware] M058 - GPIO Interrupt (0) | 2019.05.03 |
[Firmware] M058 - PWM (0) | 2019.05.03 |
[Firmware] M058 - gpio_timer_delay (0) | 2019.05.03 |
[Firmware] M058 - gpio_output/input (0) | 2019.05.03 |
Comments