 |
www.elektronik.si Forum o elektrotehniki in računalništvu
|
Poglej prejšnjo temo :: Poglej naslednjo temo |
Avtor |
Sporočilo |
SimonS Član



Pridružen-a: Čet 01 Jul 2004 11:18 Prispevkov: 4767 Aktiv.: 20.14 Kraj: Kobarid
|
Objavljeno: Pon Avg 08, 2011 6:24 pm Naslov sporočila: UART in serijski monitor na uVision |
|
|
Pozdrav
Prvič uporabljam ukaz printf, tako da mi marsikaj ni jasno.
1. je inicializacija prava? Ne morem testirati v živo.
2. kako lahko pošiljam na 2. različna UARTa?
3. Zakaj v simulatorju pri Keilu uVision4 ne dela (ne vidim) kaj se dogaja po uartu?
sprejem podatkov je OK!
pošiljam:
Koda: |
printf("\n\rUSART Printf Example: retarget the C library printf function to the USART\n\r");
|
Koda: |
int fputc(int ch, FILE * f)
{ /* Transmit the character using USART1 */
USART_SendData(USART1, (u8) ch);/* Wait until transmit finishes */
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
return ch;
}
|
Koda: |
void USART1_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate =9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No ;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1, ENABLE); /* Enabling interrupt from USART1 */
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
}
|
_________________ Lep dan
Simon |
|
Nazaj na vrh |
|
 |
|
|
Ne, ne moreš dodajati novih tem v tem forumu Ne, ne moreš odgovarjati na teme v tem forumu Ne, ne moreš urejati svojih prispevkov v tem forumu Ne, ne moreš brisati svojih prispevkov v tem forumu Ne ne moreš glasovati v anketi v tem forumu Ne, ne moreš pripeti datotek v tem forumu Ne, ne moreš povleči datotek v tem forumu
|
Uptime: 486 dni
Powered by phpBB © 2001, 2005 phpBB Group
|