| データシートサーチシステム |
|
MCP8021 データシート(PDF) 45 Page - Microchip Technology |
|
|
|||||||||||||||||||||||||||||
MCP8021 データシート(HTML) 45 Page - Microchip Technology |
|
45 / 66 page ![]() 2020-2024 Microchip Technology Inc. and its subsidiaries DS20006265D-page 45 MCP8021/2 5.2.6 AUTO-BAUD CODE EXAMPLE Example 5-1 is a dsPIC® DSC code example using the auto-baud function. EXAMPLE 5-1: dsPIC® DSC AUTO-BAUD EXAMPLE // #define FCY 70000000UL #define TypBaudrate 9600uL #define U1BRG_BAUDRATE (FCY/(16 * TypBaudrate)) - 1 #define U1BRG_BAUD_MIN ((((FCY/(16 * TypBaudrate)) - 1)*1.07f)) //plus 7% #define U1BRG_BAUD_MAX ((((FCY/(16 * TypBaudrate)) - 1)*0.93f)) //minus 7% #define U1BRG_BREAK (FCY/(16 * 7880uL)) - 1 //7880 baud-rate is midpoint of //required break window for MCP8021 void UART1_Init(void){ //UART configuration - setup PPS connections U1MODEbits.UARTEN = 1; // enable UART //and UART module enable here } void UART1_AutoBaud(void){ U1MODEbits.ABAUD = 0; int lastBRG = U1BRG; //save last known good BRG value - on POR BRG value //will be 0x0 U1STAbits.UTXEN = 1; //Transmit enabled, UxTX pin controlled by UARTx while(U1STAbits.UTXBF); //Wait for transmit buffer to empty while(!U1STAbits.TRMT); //wait for last byte to finish transmitting U1BRG = U1BRG_BREAK; //7880baud representing 1.65ms dominant //with 13bit BREAK U1STAbits.UTXBRK = 1; //Send BREAK command U1TXREG = 0x00; //Dummy write to start BREAK command while (U1STAbits.UTXBRK); //wait for completion of BREAK sequence while (!U1STAbits.TRMT); //wait for last break bit to transmit U1STAbits.UTXEN = 0; //disable TX while waiting on 0x55 from MCP8021 U1MODEbits.ABAUD = 1; //start the ABAUD counter upon receipt of //next byte (0x55) while(U1MODEbits.ABAUD); //application should handle timeout if auto-baud //does not complete and attempt auto-baud routine again //verify new baud clock is within limits of MCP8021 min and //max baud-rate if ((U1BRG > U1BRG_BAUD_MAX) && (U1BRG < U1BRG_BAUD_MIN)){ //success, use new baud-rate //generator value } else{ U1BRG = lastBRG; //auto-baud out of range, reload last known good BRG value //and attempt auto-baud routine again } } |
|
リンク URL |
| ALLDATASHEETはお客様のビジネスに役立ちますか? [ DONATE ] |
Alldatasheetは | 広告 | お問い合わせ | プライバシーポリシー | データシートへのリンク | リンク交換 | メーカーリスト All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |