assembly code problems
Jon87
Posts: 14
Hi everyone. I've been trying to learn some assembly lately but i'm having a few problems. I thought i understood all the tutorials i've done and examples i've looked at.
I'm trying to write an object to read remote control codes. I know the hardware is working. At the moment, I'm just trying to time the period when the receiver pin goes low at the start of the code and displaying that on a tv to see that its working. To be honest, i'm not sure if the problem is passing variables to and from DAT or if its something much bigger. Any pointers would be greatly appreciated, thanks
EDIT - ignore 'space' and 'mark', this isn't the way i'll be doing it when its finished
Post Edited (Jon87) : 4/27/2010 5:45:50 PM GMT
I'm trying to write an object to read remote control codes. I know the hardware is working. At the moment, I'm just trying to time the period when the receiver pin goes low at the start of the code and displaying that on a tv to see that its working. To be honest, i'm not sure if the problem is passing variables to and from DAT or if its something much bigger. Any pointers would be greatly appreciated, thanks
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ tv : "tv_text" VAR long rc5 PUB Main tv.start(12) IRrx(1) repeat tv.str(string($A,7,$B,3)) tv.dec(rc5) PUB IRrx (pin) {{Launch cog to detect RC5 codes}} _pin := pin dira[noparse][[/noparse]pin]~ cognew(@detect, @rc5) DAT org 0 detect mov addr, PAR waitpeq space, _pin 'Wait for start bit mov start, cnt 'time start bit pulse waitpeq mark, _pin mov half, cnt sub half, start 'half - start = start pulse length, should be about 71120 (80MHz * 889us) wrlong half, addr mov t, cnt waitcnt t, delay jmp #detect _pin long 0 'IR input pin space long 0 mark long 2 delay long 10_000_000 t res 1 start res 1 half res 1 'timed half period addr res 1 'PAR address
EDIT - ignore 'space' and 'mark', this isn't the way i'll be doing it when its finished
Post Edited (Jon87) : 4/27/2010 5:45:50 PM GMT
Comments
You need to put |<pin into the _pin variable. waitpeq and waitpne expect a bitmask but you gave it the pin number. At least if the SPIN code is really a 1 to 1 copy.
I think writing a IR receiver is already a sophisticated goal ... because I did it myself and know what a challange it is ;o)
( If you wanna see my code somewhen, drop a note )
I think, you will need 3 waits.
waitpeq
waitpne 'Wait for the start
waitpeq 'Wait for the end
PASD is a debugger for Propeller assembler, which can help you to develop assembler routines.
Good luck,
Christof
Well i thought i'd tried everything. it works now with the mask. thanks. i also had to add a little bit onto 't' for the delay.
I'll get on with the rest now, thanks
You've gave me an idea to use waitpne but i'm not sure what the 1st wait is for. The IR receiver pin is idle high, when a burst of IR signals at the right frequency is detected, it goes low. I'm just timing the low part
EDIT - I'm also going to check out PASD, thanks
www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp4.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
The link i've got for PASD isn't working, http://forums.parallax.com/showpost.php?p=0
I've written a bit more now and i'm receiving a code but the values seem to be all over the place. I beleive the problem is inside the loop in DAT.
To find out what's going on, i want to toggle pin 6 (or any other pin, i'm not bothered) every time the input on the rx pin is sampled so i can see it on a scope but its not toggling at all. the output is constantly low (i'm using a 10K pull-up resistor). I tested the hardware setup in spin and i was able to toggle
EDIT - Nevermind, i put "or dira, _opin" at the top of DAT and it toggles now. Why was this needed in DAT when i already had "dira[noparse][[/noparse]6]~~" in PUB IRrx?
Post Edited (Jon87) : 4/28/2010 12:39:50 PM GMT
Oh right, so i guess the "dira[noparse][[/noparse]pin]~" doesn't do anything either, i was just lucky that all pins are inputs as default?
The code's finished now and its working well. thanks everyone
Yes, pins default to inputs but it doesn't hurt to be specific, especially in your objects.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA