Discussion Forum

help with hex file output

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
valy voiculescu
Posted
6-Feb-2006 16:15 GMT
Toolset
C51
New! help with hex file output
Hello

I'm new in this programming world and I had a simple application in C that was supposed to toggle a led and set some signals...

The application was supposed to be emulated with an EPROM emulator but it doesn't work now...

I'm not sure what the necessary options should be set to create at HEX file:

I used Target/ Options for target.../Output and from the first frame selected Debug information + Browse information + Create HEX (HEX-80) file.

Is this right? Was I supposed to do something else? Or decheck Debug information + Browse information?
Read-Only
Author
Hans-Bernhard Broeker
Posted
6-Feb-2006 17:26 GMT
Toolset
C51
New! RE: help with hex file output
The application was supposed to be emulated with an EPROM emulator

That statement makes no sense. An EPROM emulator emulates an EPROM, not an application.

but it doesn't work now...

How, exactly, does it "not work"? What did you do, what did you expect to happen, and what happened instead of that?
Read-Only
Author
valy voiculescu
Posted
6-Feb-2006 19:33 GMT
Toolset
C51
New! RE: help with hex file output
Hello

Yes...The C pplication aws converted in HEx and downloaded into an EPROM emulator which holds the code for 8051.

It should have blinked some LEDS and toggle some pins from 5V to GND @ around 1KHZ...but nothing happens...

I measured with an osciloscope the pins I got a steady voltage.

My initialization seems right in terms of timer 0 interrupt activation:

P1=0xff;
P0=0xff;
P2=0xff;
P3=0xff;
PSW=0x00;
IP=0x00;
TMOD=0x22; //8bit auto reloaded
PCON=0x00; //no power down mode
SCON=0x50;
IE=0x92;
HB=0x00;//some special registers for my 8051 derivative
EPMA=0x00;

TH1=253;
TCON=0; //no ovf flags no timer running
TR1=1;
TR0=1;
Read-Only
Author
erik malund
Posted
6-Feb-2006 22:08 GMT
Toolset
C51
New! RE: help with hex file output
IE=0x92;

where is the ISR?

Erik
Read-Only
Author
valy voiculescu
Posted
7-Feb-2006 10:28 GMT
Toolset
C51
New! RE: help with hex file output
The basic interrupt serivce routine was:

void timer_isr(void) interrupt 1
{
if (count==5)

{

if (toggle)
{
P2 &= 0x00;
toggle=0;
P0 |= TEST_LED;
}
else
{
P2 |=0xff;
toggle=1;
P0 &= ~TEST_LED;
}
count=0;
}
else
count++;
}

THIS should have blinked a led and the ports...but it doesn't...and the problem could rely in 3 zones:
the HEX file was created badly or
the ucontroller
the timer0 isn't initialised properly (but why not?!?)
Read-Only
Author
erik malund
Posted
7-Feb-2006 13:19 GMT
Toolset
C51
New! RE: help with hex file output
way too fast, the LED will glow half bright. To observe a blink one in 100 can see it at 120Hz, all can see it at 25Hz

Erik
Read-Only
Author
valy voiculescu
Posted
7-Feb-2006 15:14 GMT
Toolset
C51
New! RE: help with hex file output
Ok i've modified that. But my problem was that the led was NEVER ON.

That wasn't supposed to be happening because

1. I initiated the TMOD,TCON registers...
2. I initiated IE
3. I specified the Timer0 ISR.

And by measuring with an osciloscope I saw a continuous signal at the pins...and at the XTAL...so I'm not even sure if the processor is being fed with clock signal...:(



#include <REG52.H>

void main(void)
{
unsigned int c1=0;
unsigned char c2=0;
P1 = 0x00; //light up leds
while (1)
{
/* 1.8 mhz */
c1++;
if (c1==30000)
/* 60 hz */
{
c1=0;
c2++;
if (c2==12)
{
c2=0;
P1 ^= 0xFF; //blink led and toggle all pins
}
}
}
}

I'm not sure how can I test if the Oscilation from the XTAL is ok (or if there is a component failiure).

The schematic is the usual:
gnd-10pf---------+------------+-----|X1
| XTAL=22MHz R=10MOhms |
+-10pf--------+------------+-----|X2
Read-Only
Author
Hans-Bernhard Broeker
Posted
7-Feb-2006 15:23 GMT
Toolset
C51
New! RE: help with hex file output
And by measuring with an osciloscope I saw a continuous signal at the pins...and at the XTAL...so I'm not even sure if the processor is being fed with clock signal...:(

Nothing you do with the software can ever, possibly fix a problem with the hardware like that. If you don't see the XTAL oscillating, that means either you fritzed the CPU, or you're not feeding it correctly, or you don't have a working reset circuit. Fix the hardware before you begin worrying about details of your software!

And just for the record: processors aren't usually "fed" with a clock signal, if all you attach is an XTAL. They generate that signal themselves, with the XTAL being part of the generator, determining the frequency.

Next Thread | Thread List | Previous Thread Start a Thread | Settings