Author Topic: 8051Debugging Help needed ( LED not blinking :P)  (Read 13616 times)

0 Members and 1 Guest are viewing this topic.

Offline sync

  • Frequent Contributor
  • **
  • Posts: 799
  • Country: de
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #25 on: August 12, 2013, 11:31:46 pm »
Code: [Select]
void delay(int a)
{
   int i;
   for(i=0;i<a;i++);   //null statement
}

Is that a working delay() function?
It has no result. The compiler is free to replace it with nothing.
 

Offline rohan-04Topic starter

  • Contributor
  • Posts: 45
  • Country: in
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #26 on: August 12, 2013, 11:39:36 pm »
Quirks about 8051 family in 20pin packages - port p1.0 and p1.1 is kind of open collector - those 2 pins are connected to internal analouge comparator and cannot source current. This should not be an issue here but you may try to move to some other pins.
And if you are unsure about your programing try to test your circut using Bascom 8051 or even assembly language. At least for me those two are easier than C for 8051 family.
Tried it on P3 and same issue.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9930
  • Country: nz
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #27 on: August 13, 2013, 12:38:26 am »
I doubt the issue is the delay function, even if the compiler optimized it out you'd see some light from the LED, it would just be less bright. Maybe ~30% due to pwm.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline bbarbour

  • Contributor
  • Posts: 19
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #28 on: August 13, 2013, 12:51:54 am »
I'm with Psi.  It's likely that the uC isn't actually programmed.  If you've triple checked everything with the circuit and modified the program to simply turn on the LED (as suggested above, set the pin low, not high, and connect the cathode of the LED to the pin and the anode to an appropriate voltage source), then it's likely that the controller isn't doing anything.  Unfortunately it can be challenging to confirm whether or not something is programmed successfully or not (depending on the programmer).  One thing you could do is set a pin to oscillate (blink) and use a multimeter to determine which pin is exhibiting the behavior you programmed.  That way you can remove the diode from the mix (just in case the LED is dead or something).
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #29 on: August 13, 2013, 01:00:52 am »
I agree. Not programmed.

Easiest "is it programmed" check IMHO is to program it with a simple infinite loop toggling a pin. Don't even bother with timing, you don't want to check if that's right too, you just want the pin to toggle. Add a pullup if required and toss a scope probe at it. Even better, toggle all the pins.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline JoeO

  • Frequent Contributor
  • **
  • Posts: 527
  • Country: us
  • I admit to being deplorable
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #30 on: August 13, 2013, 02:08:33 am »
I agree. Not programmed.

Easiest "is it programmed" check IMHO is to program it with a simple infinite loop toggling a pin. Don't even bother with timing, you don't want to check if that's right too, you just want the pin to toggle. Add a pullup if required and toss a scope probe at it. Even better, toggle all the pins.
He doesn't have a scope.
The day Al Gore was born there were 7,000 polar bears on Earth.
Today, only 26,000 remain.
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #31 on: August 13, 2013, 02:34:58 am »
Oops. Looks like I sold my reading comprehension to pay for my scope.

Scopeless upgrade: program it once to set all pins low, then program it again to set all pins high.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline rohan-04Topic starter

  • Contributor
  • Posts: 45
  • Country: in
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #32 on: August 13, 2013, 09:06:33 am »
I dont know if this is any good but the programmer I have has this "read" function (attached), it also has a "blank check" function that gives the appropriate messages when applied.
« Last Edit: August 13, 2013, 09:08:25 am by rohan-04 »
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5126
  • Country: nl
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #33 on: August 13, 2013, 09:23:04 am »
Well, that's empty for sure, I guess the blank check tells you that it is.
Keyboard error: Press F1 to continue.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8264
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #34 on: August 13, 2013, 12:08:34 pm »
Not exactly, that contains LJMP 082F followed by a ton of MOV R7, A.

Now go look at 82F and see if that's also all FFs or if there's something there.
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5126
  • Country: nl
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #35 on: August 13, 2013, 12:22:26 pm »
Not exactly, that contains LJMP 082F followed by a ton of MOV R7, A.

Oops.... Next time coffee first, then post  :-[

But wait: 'The AT89C2051 is a low-voltage, high-performance CMOS 8-bit microcomputer with 2K bytes of Flash programmable and erasable read-only memory (PEROM).'.
2K, isn't that from 0000-07FF?
« Last Edit: August 13, 2013, 12:36:28 pm by PA0PBZ »
Keyboard error: Press F1 to continue.
 

Offline rohan-04Topic starter

  • Contributor
  • Posts: 45
  • Country: in
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #36 on: August 18, 2013, 02:07:29 pm »
So after changing the code to suite the numerous debugging tests. I've found what seems to be problem. The desktop program "Willar Programmer" has issues with the hex files thats loaded, the error I get is  "Warning: Some data out of range has been ignored", but when I load a different hex file no such error and when I read the uC using the software it displays appropriately. So I'm guessing this is the problem.

Attached : Screenshot of the error.
« Last Edit: August 18, 2013, 02:16:34 pm by rohan-04 »
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5126
  • Country: nl
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #37 on: August 18, 2013, 05:17:29 pm »
As you can see in my last message the code starts with a jump to 082F, but your processor only has 2KB program memory (0000-07FF). That is probably also why you get this warning: in the HEX file is code that can not be programmed in the processor. Have a good look at the program (compiler?) where you generate this code, I'm sure that there is a setting wrong, like the wrong target processor or something like that.
Keyboard error: Press F1 to continue.
 

Offline rohan-04Topic starter

  • Contributor
  • Posts: 45
  • Country: in
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #38 on: August 18, 2013, 06:05:53 pm »
using uVision4. Right I'm inspecting it now. I dont see whats wrong honestly.
« Last Edit: August 18, 2013, 06:23:56 pm by rohan-04 »
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5126
  • Country: nl
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #39 on: August 18, 2013, 07:05:36 pm »
The only thing I see is the missing 'v' at the "use On-chip ROM". That could make the difference.
Keyboard error: Press F1 to continue.
 

Offline tinhead

  • Super Contributor
  • ***
  • Posts: 1918
  • Country: 00
    • If you like my hacks, send me a donation
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #40 on: August 18, 2013, 07:13:48 pm »
it could, but here µV should not care about when C2051 selected.

What i didn't really got, why you loading two hex files into programmer?

« Last Edit: August 18, 2013, 07:50:00 pm by tinhead »
I don't want to be human! I want to see gamma rays, I want to hear X-rays, and I want to smell dark matter ...
I want to reach out with something other than these prehensile paws and feel the solar wind of a supernova flowing over me.
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5126
  • Country: nl
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #41 on: August 18, 2013, 07:18:39 pm »
What i didn't really got, why you loading two hex files into programmer?

I think the second one was a test to see if it would load without a problem (Still don't want to know what it does  :o)

If it fails again can you attach the uc.hex file for inspection?
Keyboard error: Press F1 to continue.
 

Offline rohan-04Topic starter

  • Contributor
  • Posts: 45
  • Country: in
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #42 on: August 18, 2013, 07:30:14 pm »
Exactly. The second hex is the reason I'm learning the 8051, its for a speedometer for a bike :)
So yeah I built a new project with the correct settings and still a no go.

The only thing I see is the missing 'v' at the "use On-chip ROM". That could make the difference.
Code: [Select]
    MODULE:  Code.obj (CODE)
*** ERROR L120: CONTENT BELONGS TO ERRONEOUS SEGMENT
    SEGMENT: ?PR?_DELAY?CODE
    MODULE:  Code.obj (CODE)
Program Size: data=9.0 xdata=0 code=69
Target not created
I get this error on selecting it.

P.S - Its now called At89c20
« Last Edit: August 18, 2013, 07:32:57 pm by rohan-04 »
 

Offline tinhead

  • Super Contributor
  • ***
  • Posts: 1918
  • Country: 00
    • If you like my hacks, send me a donation
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #43 on: August 18, 2013, 07:48:45 pm »
no idea what you doing, when i create new project, select AT89C2051, create new C file, paste your code and compile/debug the virtual port is blinking. Zip your new project and attach/post here, maybe it is your µV version doing something ugly.
I don't want to be human! I want to see gamma rays, I want to hear X-rays, and I want to smell dark matter ...
I want to reach out with something other than these prehensile paws and feel the solar wind of a supernova flowing over me.
 

Offline rohan-04Topic starter

  • Contributor
  • Posts: 45
  • Country: in
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #44 on: August 18, 2013, 09:51:42 pm »
I guess thats the case. Should I try it with SDCC and eclipse?
 

Offline tinhead

  • Super Contributor
  • ***
  • Posts: 1918
  • Country: 00
    • If you like my hacks, send me a donation
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #45 on: August 18, 2013, 10:33:45 pm »
don't give up that fast :)

The linker is creating in your version a gap:

Code: [Select]
            * * * * * * *   D A T A   M E M O R Y   * * * * * * *
            REG     0000H     0008H     ABSOLUTE     "REG BANK 0"
            IDATA   0008H     0001H     UNIT         ?STACK

            * * * * * * *   C O D E   M E M O R Y   * * * * * * *
            CODE    0000H     0003H     ABSOLUTE     
                    0003H     07FDH                  *** GAP ***
            CODE    0800H     0018H     INBLOCK      ?PR?_DELAY?CODE
            CODE    0818H     0014H     INBLOCK      ?PR?MAIN?CODE
            CODE    082CH     000CH     UNIT         ?C_C51STARTUP
            CODE    0838H     000AH     INBLOCK      ?PR?CCT_INIT?CODE

as you working with code limited Keil version it might be an general test version issue or simply the version you have is somehow broken. I would say download the latest (9.52) and try to recompile your code. When i compile with my version (9.52 non limited), your unchanged project works as supposed to do (attached hex, so you can watch blinking LED waiting for the Keil download ready :P)
I don't want to be human! I want to see gamma rays, I want to hear X-rays, and I want to smell dark matter ...
I want to reach out with something other than these prehensile paws and feel the solar wind of a supernova flowing over me.
 

Offline rohan-04Topic starter

  • Contributor
  • Posts: 45
  • Country: in
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #46 on: August 18, 2013, 10:39:20 pm »
Yup. Its too late for me to start breadboard and see what happens but I have successfully got the application to program the uC.
Now lets see what happens with the latest issue.
 

Offline rohan-04Topic starter

  • Contributor
  • Posts: 45
  • Country: in
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #47 on: August 19, 2013, 01:27:05 pm »
Ok so while the uC accepts the hex file you gave and transfers to the controller properly, however the led still did not blink. On the other hand the new version 9.52 is still no different, same error of the data being out of range. So all we've manage to solve as of now is the fact that the programmer application and keil on my computer arent working. Could it be an OS issue? I'm using windows 8
 

Offline lapm

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: fi
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #48 on: August 19, 2013, 08:12:45 pm »
Sounds more like some sort of compiler issue. Especially since you get that out of range error.

Make sure what size of hex file compiler allows you to do, some of them allows quite small on free licences.

Might also be worth take a look at header files compiler try's to use for chip you are using. Would not be first time header files or definition files have errors them.

Then next step would probably be to identify why compiler generates too large block of code space. Blinking led should be just few commands even if you do crude delay on it. => small hex file.
Electronics, Linux, Programming, Science... im interested all of it...
 

Offline tinhead

  • Super Contributor
  • ***
  • Posts: 1918
  • Country: 00
    • If you like my hacks, send me a donation
Re: 8051Debugging Help needed ( LED not blinking :P)
« Reply #49 on: August 20, 2013, 01:22:43 pm »
the same compiler/µV version, but licensed, is working properly. The only diff is the extra gap space, so for me it looks like a bug in linker.

EDIT: a bit unfair to let beginner to fight with compiler ^^ So i installed trial version and it does not work as well. That means that the trial license is breaking the code (adding the gap while linking).
« Last Edit: August 20, 2013, 01:35:10 pm by tinhead »
I don't want to be human! I want to see gamma rays, I want to hear X-rays, and I want to smell dark matter ...
I want to reach out with something other than these prehensile paws and feel the solar wind of a supernova flowing over me.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf