IN THE KNOW
Go to bottomPage: 1
TOPIC:
*
#756
Z8F1680 LED Drive Sample Code 2 Years ago Karma: 0
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.
batmannemesis (User)
Fresh Boarder
Posts: 8
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1