Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "MKL46Z4.h" // Biblioteka wykorzystywanej plytki.
- //#include "lcd.h" // Biblioteka obslogi wyswietlacza lcd.
- //#define UART0_Rx 0 //Rx is first in table
- //#define UART0_Tx 1 //Tx is second in table
- void init_UART(void){
- SIM->SCGC4 |= SIM_SCGC4_UART2_MASK; // Odblokowanie zegara dla UART2. /* Enable Clock to UART2*/
- SIM->SCGC5 |= SIM_SCGC5_PORTE_MASK; // Odblokowanie zegara dla portu E. /* Enable Clock to PORTA*/
- PORTE->PCR[16] |= PORT_PCR_MUX(3UL); /* Pin PTA1 is alt2 (UART)*/
- PORTE->PCR[17] |= PORT_PCR_MUX(3UL); /* Pin PTA2 is alt2 (UART) */
- UART2->C2 &=~ UART_C2_TE_MASK; // /* disable transmitting*/
- UART2->C2 &=~ UART_C2_RE_MASK; /* disable receiving */
- UART2->BDH |= UART_BDH_SBR(0x156); /*set value of SBR to BDH (it is the first divider)0x01*/
- UART2->BDL |= UART_BDL_SBR(0x156); /*set value of SBR to BDL */
- UART2->BDH &=~ UART_BDH_SBNS_MASK; /*set value of SBNS (0 - one bit, 1- two bits) 0x38*/
- UART2->C1 &=~ UART_C1_M_MASK; // 8 bitow danych. /* M selects between 8 and 9 bits data MODE*/
- UART2->C1 &=~ UART_C1_PE_MASK; // Brak bitu parzystosci. /* PE - parity enable (0 - no hardware parity)*/
- UART2->C2 |= UART_C2_TE_MASK; /* enable transmitting*/
- UART2->C2 |= UART_C2_RE_MASK; /* enable receiving */
- }
- int main (void) {
- uint8_t data = 255;
- init_UART();
- //init_LCD(); // Inicjalizacja wyswietlacza lcd.
- for(;;) {
- //set_float_LCD(3.789,3);
- //while( (UART0->S1 & 0x80) != 0) {
- UART2->D='a';
- //}
- //while( (UART0->S1 & 0x80) != 0);
- delay(1000);
- //set_float_LCD(1.121,3);
- delay(1000);
- //delay(1000);
- //delay(1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement