Created
July 5, 2022 08:23
-
-
Save rk76feWF/5d779b0521b2b0978d296a00b8172f48 to your computer and use it in GitHub Desktop.
uart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setUART() | |
{ | |
// UARTのピンの設定 | |
_TRISD0 = 1; // RX | |
_TRISD11 = 0; // TX | |
_U1RXR = 11; // RX | |
_RP12R = 3; // TX | |
// UARTモジュールの設定 | |
U1MODE = 0x0000; | |
U1STA = 0x0000; | |
U1MODEbits.BRGH = 1; // 高速ボーレートモード | |
U1BRG = 103; // ボーレート設定 | |
_U1RXIE = 1; // 割り込みを有効化 | |
_U1RXIF = 0; // 割り込みのフラグを下げる | |
_U1RXIP = 1; // 割り込み優先度の設定 | |
U1MODEbits.UARTEN = 1; // UART有効化 | |
U1STAbits.UTXEN = 1; // 送信有効化 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment