jeffafa
Newbie level 2
- Joined
- Oct 7, 2013
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 17
Hello everybody,
I wrote a simple code to blink a led every 1 second for a AT89C2051. The code was writen using Keil uVision 4 with the C51 compiler V9.02 full version. To program the code into the mcu I use a Galep-5 programmer.
When i run the code in the simulator everything works like i would expect it. But when i run it on the mcu nothing happens. Only after i play a little with the RST pin does the led turn on but doesn't start blinking. I think the MCU is stuck in reset so i used the setup in the datasheet but still nothing. After a google search i found a schematic for a dev board so i used that setup but still nothing. (https://www.qsl.net/vu2upx/Projects/2052devbrd.htm)
I could really use some help.
I have included my code:
Thanks in advance!
I wrote a simple code to blink a led every 1 second for a AT89C2051. The code was writen using Keil uVision 4 with the C51 compiler V9.02 full version. To program the code into the mcu I use a Galep-5 programmer.
When i run the code in the simulator everything works like i would expect it. But when i run it on the mcu nothing happens. Only after i play a little with the RST pin does the led turn on but doesn't start blinking. I think the MCU is stuck in reset so i used the setup in the datasheet but still nothing. After a google search i found a schematic for a dev board so i used that setup but still nothing. (https://www.qsl.net/vu2upx/Projects/2052devbrd.htm)
I could really use some help.
I have included my code:
Code:
#include <reg2051.h>
#define high 1
#define low 0
/*-----------------------------------------------------------------------------
Definitions for P1 (8 bits)
-----------------------------------------------------------------------------*/
volatile unsigned int overflow_count = 0;
void timer0_ISR (void) interrupt 1
{
overflow_count++; /* Increment the overflow count */
}
/*------------------------------------------------
MAIN C function
------------------------------------------------*/
void main (void)
{
/*--------------------------------------
Set Timer0 for 16-bit timer mode. The
timer counts to 65535, overflows, and
generates an interrupt.
Set the Timer0 Run control bit.
--------------------------------------*/
TMOD = (TMOD & 0xF0) | 0x00; /* Set T/C0 Mode */
TL0 = 31; /* Prescaler */
TH0 = 255; /* Full counter */
ET0 = 1; /* Enable Timer 0 Interrupts */
TR0 = 1; /* Start Timer 0 Running */
EA = 1; /* Global Interrupt Enable */
P1_3 = high;
/*--------------------------------------
Do Nothing. Actually, the timer 0
interrupt will occur every 65536 clocks.
--------------------------------------*/
while (1)
{
if(overflow_count >= 244L)
{
overflow_count = 0L;
if (P1_3 == 1) P1_3 = 0;
else P1_3 = 1;
}
}
}
Thanks in advance!