hi. I am writing the keyboard driver (using the UART and RS232 protocol). There is an Receive Fifo And one Flag register.when there is an data in receiver fifo the Flag get changed. i am reding the reading the receiver fifo depend on the Flag register (if the receive flag set).but on debugger when i see the Flag register the Flags are not changing? for example : "when the flag which tell there is data in Rx fifo set and then when i do the read operation this flag should get cleared" but it is not getting cleared.. need ur help as soon as possible Thanks
facing Problem while writing UART driver
Started by ●June 26, 2006
Reply by ●June 27, 20062006-06-27
rahul wrote:> hi. > I am writing the keyboard driver (using the UART and RS232 protocol). > There is an Receive Fifo And one Flag register.when there is an data in > receiver fifo the > Flag get changed. i am reding the reading the receiver fifo depend on > the Flag register > (if the receive flag set).but on debugger when i see the Flag register > the Flags are not changing? > for example : "when the flag which tell there is data in Rx fifo set > and then when i do the read operation this flag should get cleared" > but it is not getting cleared.. > > need ur help as soon as possible > Thanks >Hi Rahul, Please give a code sample and some information on what chip you are using, and what debugger etc. Ross
Reply by ●June 27, 20062006-06-27
hi ross the program goes like this while(1) { while ((HOSTSYNC & 0x00000001) != 0x00000001); /* keyboard is connected */ for(i=1;i<3900;i++); while ((HOSTSYNC & 0x00000001) != 0x00000001); HOSTSYNC_FLAG = 1; /* this is the time flag */ RTS = 0x000A0000; /* assert the RTS signal */ USTCNT = 0x40F842D8; if ((UTXRX & 0x08000000)==0x08000000) { PTR = UTXRX; RTS = 0x00020000; } if ((UTXRX & 0x10000000)==0x10000000) { PTR = UTXRX; RTS = 0x00020000; } if (HOSTSYNC_FLAG == 1) { for(i=0;i<39000;i++); /*this shows that there is no data from Keyboard make RTS low after 500ms*/ RTS = 0x00020000; } where the hostsync is made high by the keyboard.and the MICON-Board will produce the RTS signal in responce to the high on the Hostsync. The UART registers are the USTCNT : the control register UTXRX : the status register of UART Ross Marchant wrote:> rahul wrote: > > hi. > > I am writing the keyboard driver (using the UART and RS232 protocol). > > There is an Receive Fifo And one Flag register.when there is an data in > > receiver fifo the > > Flag get changed. i am reding the reading the receiver fifo depend on > > the Flag register > > (if the receive flag set).but on debugger when i see the Flag register > > the Flags are not changing? > > for example : "when the flag which tell there is data in Rx fifo set > > and then when i do the read operation this flag should get cleared" > > but it is not getting cleared.. > > > > need ur help as soon as possible > > Thanks > > > > Hi Rahul, > > Please give a code sample and some information on what chip you are > using, and what debugger etc. > > Ross
Reply by ●June 27, 20062006-06-27
"rahul" <chaudhari.rahul.r@gmail.com> wrote in message news:1151385428.841620.189740@i40g2000cwc.googlegroups.com... <snip code> Two things jump out straight off: for(i=1;i<3900;i++); Be sure that the compiler doesn't optimise this out. and: if ((UTXRX & 0x08000000)==0x08000000) { PTR = UTXRX; This will probably read the UTXRX register twice. I don't know what device you're using but the first read may clear the register - it often does at the top of a FIFO. More info on your device is needed to answer your question.
Reply by ●June 27, 20062006-06-27
"Tom Lucas" wrote:>"rahul" <chaudhari.rahul.r@gmail.com> wrote ><snip code> > >Two things jump out straight off: > >for(i=1;i<3900;i++); >Be sure that the compiler doesn't optimise this out. > >and: > >if ((UTXRX & 0x08000000)==0x08000000) >{ > PTR = UTXRX; > >This will probably read the UTXRX register twice. I don't know what >device you're using but the first read may clear the register - it often >does at the top of a FIFO. > >More info on your device is needed to answer your question.In addition to what others posted, make sure all the control registers are declared with the "volatile" modifier. Otherwise you code may not read the actual register value when you expect it.