CAN koli od razloži mi to zanko "while (! (U1LSR &

A

angy

Guest
Delam na UART na LPC21XX.
Prišel sem acroos naslednji pogoj "while (! (U1LSR & 0x20));"
Nisem mogla razumeti zgoraj zanke. Help plz
popolna oznaka
# define CR 0x0D
# include <LPC21xx.H>

void init_serial (void);
int putchar (int ch);
int getchar (void);unsigned char test;

int main (void)
(
VPBDIV = 0x02; / / Divide Pclk dva
init_serial ();

while (1)
(

putchar (getchar ()); / / Echo terminala
)
)

void init_serial (ničen) / * Initialize Serial Interface * /
(
PINSEL0 = 0x00050000; / * Enable RxD1 in TxD1 * /
U1LCR = 0x00000083; / * 8 bits, no Parity, 1 Stop bit * /
U1DLL = 0x000000C2; / * 9600 Baud Rate @ 30MHz VPB Clock * /
U1LCR = 0x00000003; / * DLAB = 0 * /
)int putchar (int ch) / * Write znak Serial Port * /
(

if (ch == '\ n') (
while (! (U1LSR & 0x20));
U1THR = CR; / * izhod CR * /
)

while (! (U1LSR & 0x20));

return (U1THR = ch);
)int getchar (void) / * Read značaja iz Serial Port * /
(

while (! (U1LSR & 0x01));

return (U1RBR);
)

 
Če BIT5 (00x00000) of U1LSR nič, ostane izvajanje kode v zanki.Enako kot: while ((U1LSR & 0x20) == 0);

 

Welcome to EDABoard.com

Sponsor

Back
Top