Re: hi all Help me out




"rahul" <chaudhari.rahul.r@xxxxxxxxx> wrote in message
news:1150855041.213774.24310@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hi everybody..
I am new in the Embedded programming ..
i am writting the keyboard driver for microprocessor..
the status of UART tells me if any data (from keyboard) received or not
from the flag register
the flag register is of 32 bit ...

1) How can i check the pericular bit in this register set or not?

I normally use a bit mask such as if you want to look at bit 2 (0100b or 4h)
then bitwise AND the flag register with the bit's number - i.e if
(FlagRegister & 0x04) {. Since you are working with a UART remember that
doing this on the data register counts as a read and will (normally) pop the
value off the top of a FIFO, if you are using one.

2) the receiver buffer is of 32 bit but data from keyboard comes in
8bit format..
How can i seperate the 8bit from 32 bit receiver buffer?

Which microcontroller is this specifically - you mentioned it was ARM7? I
think you'll probably find that only the lower eight bits of the 32bit word
contain recieved data. If the UART is anything like the Sharp one I've
worked with (and some others) then bits 8, 9, 10 and 11 will contain error
flags too.

So, to (possibly) answer both your questions I would try something like:

unsigned char RxCharacter;
unsigned int DataWord;

// Pointers to UART registers - likely to be different on your system.
unsigned int *DataReg = 0xFFFC0000; //Pointer to data register.
unsigned int *FlagRegister = 0xFFFC0018; // pointer to flag register

while ((*FlagRegister & 0x10)); // loop until bit 4 of the flag register
gets cleared.
// On my uart this means something has been received. Potentially infinite
loops
// are BAD though so find a better way - this is just an example.

DataWord = *DataReg; // Read the data register (may pop a FIFO)

if (DataWord & 0x0F00) { // check if any of the error bits are set - if the
UART supports this
return ERROR; // quit if they are
}
else { // otherwise store the data
RxCharacter = (unsigned char)DataWord; // use a cast to strip off the
top 24 bits.
}

This will work on a Sharp 79524 ARM7 but your device may be similar.


.



Relevant Pages

  • Re: PXA255 UART stop bit
    ... When you set a UART with 2 stop bits, this only affect the transmitter settings, for the receiver there is no impact. ... If there is a framing error, like a received character with invalid stop bit, the FE flag will indicate this. ... So my question is if it is possible to read this status out of the UART in any way through currently available interface, or do I have to read this register by my own code? ... My Windows XP PC is sending data with 1 stopbit to my WinCE 5.0 PXA255 based target receiving the data with 2 stopbits. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: H8/3867 Synchronous Uart False Clocks...
    ... An attempt to reset the uart, ... Why do I need to reset the receiver? ... >>I have tried toggling the RE bit, ...
    (comp.arch.embedded)
  • Re: 40kHz Infrared Serial Modulation?
    ... If you are using a UART on a micro controller, ... To ensure you receiving UART locks on to the signal send a header that ensures synchronization. ... Your receiver algorithm then waits for either 33 or CC to be received. ... and doesn't say much, if anything, IIRC, about the data format. ...
    (sci.electronics.design)
  • Re: Using UART with a Fujitsu microcontroller
    ... >communicate over UART. ... Everything works fine, if I transmit only ... are you sure that the receiver isn't simply seeing an all-zero byte ...
    (sci.electronics)