??? 05/26/06 09:35 Read: times |
#117132 - Various problems Responding to: ???'s previous message |
Okay, let's take a look.
Your code doesn't work on a very basic level. Furhthermore there are some issues with your code which I will briefly point at, but which are academic because the whole program will not run now anyway. First, you never mention what controller at what clock speed or which ADC you are using and you don't show any circuit diagrams. That makes it impossible for anyone to say if what you are attempting to do inside your program in terms of bit banging control lines makes any sense. Might be, might be not, impossible to say without all info. The START_CLK routine looks funny. Probably you removed the EOC check there because you are working with a simulator, and therefore have no working ADC chip connected anyhoo. Now I guessed that, but you should understand that unsuspecting people reading your code for the first time will NOT GUESS this (there is no such thing as a mind reader), and you should do a better job of pointing out WHAT you are doing and WHY. Also, use simulators with care. They should not be seen as substitutes for real chips. They are fine for checking your program flow though, and there's what really stuns me: that you attempted to run this code through a simulator, and that you did not see, or were unable to fix, the very, very basic flaw in your code I will reveal near the end of this reply. There are unclarities and contradictions in your comments. For instance, there is confusion about the polarity of OE. because to read the ADC you SET OE, while some lines above, one of your comments reads: "enabling the A/D send information" while clearing OE... Now I'm confused? Be careful and concise writing your comments! Your "compare" routine is really very funny spaghetti code! It made me quite dizzy. It could be rewritten as: compare: CJNE A,#101010b,label label: mov phone,c jmp begin _________________________________________________________________________________ But there is more structural trouble in your code! You are not observing a good flow! You are calling and never returning, and returning without ever calling and that sort of stuff! This is basic housekeeping! So let's look at your code from that level: First, I'll strip your code from any instructions which are not jumps and calls to other parts of your program: org 0000h ljmp 0100h int: lcall START_CONV begin: lcall compare START_CONV: ret Compare: jmp begin There are two huge, basic problems at this level already! 1) You are jumping to address 100 right away, but you don't locate any code there, so what do you expect the CPU to find there? This is why your program never even begins to do anything, assuming that this IS the real code you posted... 2) IF you would ever get around to int: the controller would execute like this: lcall START_CONV stack 1 ret stack 0 lcall compare stack 1 jmp begin stack 1 lcall compare stack 2 jmp begin stack 2 lcall compare stack 3 jmp begin stack 3 lcall compare stack 4 jmp begin stack 4 So you see, START_CONV will NEVER be executed again, while "begin" keeps calling Compare and Compare never properly returning, so your stack quickly fills up, overwriting your whole internal RAM with garbage. A solution would be to structure your code like this: org 0000h ljmp 0100h org 0100h ;If you jump to 100, make sure something's there! int: lcall START_CONV begin: ;This is what is known as a "main loop" lcall START_CONV lcall Compare jmp begin START_CONV: ret Compare: ret But your problems really already start on line 2... |
Topic | Author | Date |
Problem on a code | 01/01/70 00:00 | |
clean up | 01/01/70 00:00 | |
Thanks | 01/01/70 00:00 | |
Still doesn't work.. | 01/01/70 00:00 | |
evidence | 01/01/70 00:00 | |
What about open collector on port 0? | 01/01/70 00:00 | |
Various problems | 01/01/70 00:00 | |
How to post code | 01/01/70 00:00 | |
20 different simulators![]() | 01/01/70 00:00 |