Saturday, August 30, 2008

AT89C51 Led chaser WIP

I am a newbie getting into programing micro controllers. Not really know what to buy I bought a programmer that did ATMEL chips as they seem pretty cool and have a good community following at avrfreaks.

So having bought the atmel programmer from futurlec and some chips that were supported.

I am using the Keil C51 ide, which i find pretty nice. Here is my current project code (hosted @ rapidshare.de).

The code is changed slightly from some examples I found at blitzlogic and a few others. Turning Port 0 / 1 on seems to be a fairly common test.

In addition to being new (well revisting something I havent done for 10 years) at micro controller programing I am also fairly rusty at electrontics (same 10 year deal). I am working off a 6v lantern (rectangular) battery as a power source and its all wired up on the bread board.

The 10Mhz crystal was used because its all that dicksmiths had and Im still waiting for my 2nd order from furturlec.

Now that I have explained all the above, here is the issue I (and most newbs)
have - IT DOESNT WORK :(.

ISSUE:
  • LEDS 1&2 light up at ~50% brightness and LED 3 at ~20%.
  • LEDS dont work as expected.
Parts:
  • 1x AT89C51
  • 1x 8.2k ohm resistor
  • 8x 300 ohm resistors
  • 8x 3mm 2.1v LEDS
  • 1x 10Mhz SPK Crystal
  • 2x 33pf Caps
  • 1x 10uF Cap
  • 1x 6v Lantern battery
I would appreciate if anyone could offer insite to the issue, it could possibly be my code.

Update:
I have run my hex file in the keil simulator (after I figured out how) and all PO.0 to P0.7 are getting their on / off in sequence (shown in small screenshot below).

So perhaps Its not the code (I wont rule it out till I hear from someone in the know). Im leaning more to my wiring, though the bread board layout is as simple as you could possibly get.

Code:

*full rar of keil project*

leds1.c:
#include <>

char const num[ ] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};

void wait (void)
{ ; /* wait function */
}

void main( void )
{
unsigned int i;
unsigned char j;

P0 = 0; /* initialize ZERO to P0 */

while(1)
{
for( j = 0; j < p0 =" num[" i =" 0;" face="Georgia,serif">


No comments: