Re: hi all Help me out
- From: "Tom Lucas" <news@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 21 Jun 2006 09:36:55 +0100
"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.
.
- References:
- hi all Help me out
- From: rahul
- hi all Help me out
- Prev by Date: Re: SED1335 LCD Controller: Screen Disturbance
- Next by Date: Re: Linux or NetBSD on my Linksys BEFW11S4
- Previous by thread: Re: hi all Help me out
- Next by thread: new Neuros ARM & multimedia developer "board" (texas instruments)
- Index(es):
Relevant Pages
|