|
for those who want to test the LED drive feature of Z8F1680, here is the sample code:
////////////////////////////////////////////////////////////
#include <ez8.h>
void main (void)
{
unsigned int i;
OSCCTL0 = 0xE7;
OSCCTL0 = 0x18;
OSCCTL0 = 0x80;
PCDD &= ~0x08; //PC3 output (LED D4 on dev kit board)
PCOC &= ~0x08; //PC3 push pull
PCAF |= 0x08; //set alternate function
PCAFS1 |= 0x08; //LED function
LEDEN |= 0x08; //led drive enable
PCOUT &= ~0x08; //LED ON (set as active logic0)
while (1)
{
/*20mA drive */
LEDLVLH |= 0x08;
LEDLVLL |= 0x08;
for (i=0; i< 0xFFFF; i++); //delay
/*17mA drive */
LEDLVLH |= 0x08;
LEDLVLL &= ~0x08;
for (i=0; i< 0xFFFF; i++); //delay
/*13mA drive */
LEDLVLH &= ~0x08;
LEDLVLL |= 0x08;
for (i=0; i< 0xFFFF; i++); //delay
/*3mA drive */
LEDLVLH &= ~0x08;
LEDLVLL &= ~0x08;
for (i=0; i< 0xFFFF; i++); //delay
}
}
/////////////////////////////////////////////////////////////
with this code, LED on PC3 varies intensity due to variation of current drive strength.
|