It is time to connect the XE164 KeyChain to the display. I start from the XE164 KeyChain schematic: it is published by Infineon at (also Eagle Layout is available). Based on this, I created the list of used I/Os (it is easier to show it instead of explayining it):
One important note is to presenve the HWCFG[0] = HWCFG[1] = 1 otherwise the uC will not boot from internal flash memory (this I/Os have been already pulled, but if you connect some external circuit, it could be that this sink too much current during boot phase changing the HWCFG[0-1] state).
So, Display digit selection is made by using P0 port (bits 0..5), the digit dot is connected to P0.6, while the digit value is driven by port P1 (bits 0..3):
this simplify a lot the SW:
//****************************************************************************
// @Function void Display
//
//----------------------------------------------------------------------------
// @Description Convert the Character code into I/O port level
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters
// num: 0-9 number to be displayed on the 7 segment LED
//
//----------------------------------------------------------------------------
// @Date 12/17/2008
//
//****************************************************************************
void Display(char num)
{
IO_vWritePort ( P1, 0x0F & num );
}
//****************************************************************************
// @Function void SelectDigit
//
//----------------------------------------------------------------------------
// @Description Select one 7-segment display digit
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters
// num: 0-5 digit selector
//
//----------------------------------------------------------------------------
// @Date 12/17/2008
//
//****************************************************************************
void SelectDigit(char num)
{
IO_vWritePort ( P0, 0x01 << num );
}
void GPT1_viTmr4(void) interrupt T4INT
{
if ( ucDisplayDigit[ucIdx] != 0xFF )
{
SelectDigit ( 0 ); // Deselect any DIGIT
Display ( ucDisplayDigit[ucIdx] );
// DOT driver
if ( ucDisplayDigit[ucIdx]>>4 )
IO_vSetPin ( IO_P0_6 );
else
IO_vResetPin ( IO_P0_6 );
SelectDigit ( ucIdx );
}
ucIdx++;
if ( ucIdx > 5 ) ucIdx = 0;
} // End of function GPT1_viTmr4
Saturday, February 28, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment