|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
|||
|
|||
|
I'm Stuck!!! For a project i have to switch on an led and switch it off with a 5 second delay
Writing Assembler for the Rabbit is a nightmare, its a Z80 family chip that runs at 22.1 mhz and i just can't get it to run loops for timing! when i try to use subroutines it terminates the program everytime it hits RET for some reason. I'm not worried about that just now, i figure i'll sort that out when i get it to work! This was the basic format i started out with but due to terminating everytime it hit RET i abandoned this SUBR: LD A,0x255 LOOP: DEC A JP NZ,LOOP START: CALL SUBR LD A,0x084 IOI LD (SPCR),A LD A,10B ;Adress of desired LED IOI LD (PADR),A CALL SUBR LD A,0x084 IOI LD (SPCR),A ;84 Hex makes serial port ontrol register an output LD A,0B ;0 binary switches all leds off IOI LD (PADR),A ;Led location JP Z,START I know the time in this isn't 5 seconds but it should be enough to notice the LED swithing on and off START: LD DE,0xFFFF ;This loop should be somewhere between half a sec and a second LOOP2: LD HL,0x32 LOOP1: DEC HL JP NZ,LOOP1 DEC DE JP NZ,LOOP2 LD A,0x084 IOI LD (SPCR),A ;see above LD A,10B IOI LD (PADR),A LD DE,0xFFFF LOOP4: LD HL,0x32 LOOP3: DEC HL JP NZ,LOOP3 DEC DE JP NZ,LOOP4 LD A,0x084 IOI LD (SPCR),A LD A,0B IOI LD (PADR),A JP Z,START The board just switches the LED on, this is the best i've been able to get from it, just to swith the LED on! I'd think it was getting stuck in the loop or i'd coded it wrong but it switches on, the only thing i an think of is that the time delay part just isn't working and its looping from start to finish switching on and off that fast it's not noticeable that it does it I know from other programs as part of this assignment that the LED switch on and switch off parts are right, i also know that it lets me use loops as i used them in another question to achieve a logical AND with 2 switches and an LED. It all sounds so simple, but it seems that it really isnt. I'd be grateful for any help, or a pointer in the right diretion. This is an In course assesment, we're all new to assembler and we've been told we lose marks for asking questions, and that its a self learning excersise. This is as far as i've got and i'm waaaaaay ahead of the rest of the class ![]() |
|
#2
|
|||
|
|||
|
According to my calculations the delay with that should be about a second
|
|
#3
|
||||
|
||||
|
Using loops for timing is generally a bad idea, especially on a processor which can change it's cycle speed dynamically as the Rabbit can. You would do better to use the integrated RTC (which I found mentioned in the online documentation), though you would either have to poll it, or set up an interrupt handler and have the program wait on it.
As for why it was halting on return, that's easy: the program doesn't start automatically at START, but at the first instruction assembled in the program, if I understand correctly (I may be wrong, if there is a monitor program loading the code which treats START as sacred the way main() is in C, but from what I've read I don't think that's the case). The way you had it originally, the program was actually starting at SUBR, which meant that it was never even running the main program, if that is the case: when it reached the RET, it returned to where the current top of the stack points to (probably a system monitor, otherwise it would crash outright). You need to place the subroutines after the main routine, or else have a jump to START at the beginning of the code before anything else runs. Speaking of the stack, did you make sure that there was a valid stack space before trying to do subroutine calls? I don't know enough about programing this system to say what, if any, preparation you need to make for that.
__________________
Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF #define KINSEY (rand() % 7) λ Scheme is the Red Pill Scheme in Short • Understanding the C/C++ Preprocessor Taming Python • A Highly Opinionated Review of Programming Languages for the Novice, v1.1 FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov Last edited by Schol-R-LEA : March 2nd, 2008 at 01:39 PM. |
|
#4
|
|||
|
|||
|
Thanks for the information on this, i just wanted to add that i'm completely new to Assembler language and everything i've got so far is what i've learned myself over the past week from books on z80 and the online documentation on the rabbit.
I looked at the real time clock on the rabbit, i just couldn't get my head around what i needed to do to make it work. I still have a few weeks before this assignment is due in and this is all i'm stuck on, i know i've definately got a pass for it but i really want to get this working! I'll look up the poll instruction and see if i an figure out how to call the RTC and make it work, in the meantime is there any chance of some hints towards the code?? and CHEERS! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > Assembly - Z80 Assembler for RABBIT 2000 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|