PDA

View Full Version : Is there something difficult with 'waitpeq'?



Harley
08-30-2007, 06:54 AM
Help, someone!
For some reason I'm having trouble getting 'waitpeq' to work.· Here's the code for this cog.· If I just enable the ''···waitpeq·· BM1mask,BM1mask" line, that instructions works; the 50 nsec pulse is emitted.· If the next line is also enabled on it's own, nada.
I'm 'burning up' the EPROM with all the iterations I've gone through the past week+.· Going bonkers on this seemingly simple code.· I'm probably doing something very stupid.· Or totally misinterpreted the manual on one or more instructions.·


PUB BAbusRdInit
id := cognew(@BAbusRd,@SBPt) ' setup the BAbus 'comparator' breakpoint
DAT
''****************************************
' BAbus comparator - SBPt = breakpoint value, bit 16 set, upper 15 bits Zeroed
''***************************************
org 0
BAbusRd mov mem,PAR ' get value @SBPt
or DIRA,INTRmsk ' set /INTR pin to output
or OUTA,INTRmsk ' set HI
loop1 rdlong BAcomp,mem ' get value @SBPt
' or BAcomp,BM1mask ' set bit 16 HI
' and BAcomp,BAbusMask ' mask off hi 15 bits
wrlong BAcomp,mem 'TEST, and show in SBPt in VP
loop2 '
' waitpeq BM1mask,BM1mask ' wait for BM1 HI level
waitpeq BAcomp,BAbusMask ' wait for breakpoint compare
' mov temp1,INA ' get inputs
' and temp1,BAbusMask ' mask off unused
' cmp temp1,BAcomp wz ' set flag if match
' if_nz jmp #loop2

' wrlong BAcomp,mem 'TEST, and show in SBPt in VP
xor OUTA,INTRmsk ' output negative pulse
or OUTA,INTRmsk '
waitpne BM1mask,BM1mask ' wait for BM1 LO level
jmp #loop1 ' TESTING; loop forever
' jmp #BAbusRd ' TESTING; loop forever

' cogid :id ' waitpeq State, Mask ' where state=breakpoint,
' cogstop :id ' and mask=0001FFFF
:id LONG 0
INTRmsk LONG |<19 ' mask for /INTR pulse on pin 19; REALLY S/B on 21
BM1mask LONG $0001_0000 ' mask for only BM1 pin (A16)
'BAbusMask LONG $0001_FFFF ' BM1 + 16 addr bits
BAbusMask LONG $0001_000F ' BM1 + 16 addr bits
temp1 res 0
BAcomp RES 1 '
mem RES 1


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

Mike Green
08-30-2007, 07:57 AM
What's the value of SBpt? You use this to set BAcomp which is used in the WAITPEQ in question.

Harley
08-30-2007, 11:20 AM
Thanks Mike,

SBPt can range from 0000h to FFFFh in Spin, it is manually entered via a keypad i/f to another Prop. I'm trying to debug this small amount of assembly code. I'm just getting started learning Prop asm and realizing the 'separation' of cogs. For some reason I figured one could just pass values easily into and out of a cog. Well, via the Hub, right?

Yes, I'm trying to set up a WAITPEQ for 17 consecutive lsb bits. The WRLONG was only to send the BAcomp value back so I could view it in ViewPort. VP isn't set up to directly capture an assembly cog's variables. Sigh!

Is this description clear enough?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

deSilva
08-30-2007, 11:02 PM
You have a lot of out-commented code in your program that shows you tried many things, e.g..:


' mov temp1,INA ' get inputs
' and temp1,BAbusMask ' mask off unused
' cmp temp1,BAcomp wz ' set flag if match
' if_nz jmp #loop2



Did that work? It is nearly equivalent to the WAITPEQ, except for the timing...
(....
Edit: Sorry, I had posted nonsens here!
.....)

But I still have no I idea what prevents your code from working. Are you really sure you provide the correct signals to the pins??

Post Edited (deSilva) : 8/30/2007 6:25:08 PM GMT

Harley
08-30-2007, 11:37 PM
Thanks deSilva for looking at my problem code.

Yes, I have tried many different things and arrangements. To no avail.

Using ViewPort I can stop capture and view that the desired states do exist on the pins at the time BM1 is true. I was hoping one of the two Props had a problem, but NO. So it isn't in the Prop, but in my code. The WRLONG was to write back the BAcomp value to view its results, which appears OK.

Wish Parallax had a simulator for the Prop. I'd used PICs in the past and Microchip's simulator was a very good tool for getting a cleaner start on one's code. ViewPort is quite helpful for me.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

deSilva
08-30-2007, 11:58 PM
I looked again into the manual. I thought for a moment that funny "C-flag-for port-B" could have bitten you, but it said cklearly the Prop I does use portA only.

But I cleared a misconception I had for monthes: The WAITPEQ doe not check WRT the mask, but exactly does what I copied and quoted from your posting: It ANDs the INA and compares to the complete check value.

So, if that check value contains bits outside the mask it will not work!!


O.K. I see your


' and BAcomp,BAbusMask ' mask off hi 15 bits


Another wrong suspect...

BUT THIS IS OUT-COMMENTED -> TRY IT!

Post Edited (deSilva) : 8/30/2007 5:50:28 PM GMT

Kaio
08-31-2007, 12:41 AM
Harley,

why you don't use POD for assembly debugging? If you set a breakpoint after the waitpeq or later you could run your program at realtime and then you could inspect Cogs memory what's going on. I know that VP can observe variables but that is not possible in realtime.

Thomas

Harley
08-31-2007, 04:45 AM
Kaio said...
Harley,
why you don't use POD for assembly debugging? If you set a breakpoint after the waitpeq or later you could run your program at realtime and then you could inspect Cogs memory what's going on. I know that VP can observe variables but that is not possible in realtime.
Thomas


Thanks Kaio. That sounded like a swell idea, until I downloaded POD and read the requirements.

Can't use POD because of the limitations:
1. This project is on a pcb with 2 Propellers and about 20-some other TTL ICs. The Props use signals from the TTL section.

2. No provisions for a PC keybd. There are hardly any spare I/Os nor is the enough spare cogs for POD and a keyboard object.

3. I am using the TV object; it probably would conflict with PODs use.

I will retain it for later use though. Recall seeing it mentioned before but wasn't ready for such then. Thanks in advance for later use..

Too bad POD doesn't run with the USB PropPlug and a PC and display there. And only take one cog. That is minimal Prop resources; pins, cogs, etc.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

Paul Baker
08-31-2007, 04:58 AM
Ariba's PropTerminal (http://forums.parallax.com/showthread.php?p=649540) was designed to "emulate a keyboard, mouse and TV-Text-Display with the PC" and was tested with POD.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)

Harley
08-31-2007, 05:11 AM
Thanks Paul for the suggestion of Ariba's PropTerminal.

Never though a neat instruction as WAITPEQ could cause such grief. But I'm not done 'hammering' on this problem yet.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

Harley
08-31-2007, 06:12 AM
deSilva,

Sorry, I didn't explain ALL the details.

In Spin I'm doing the OR and AND equivalent (SBPt := $0001_0000) and combining the 16-bit address before it being picked up by the asm cog. So this avoided one possible problem I thought might be happening. So the high 15 bits s/b masked off!

·'······and·······BAcomp,BAbusMask········'··mask· off·hi·15·bits

That line has been used and tried, but doesn't help.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

deSilva
08-31-2007, 12:56 PM
You have changed the former "high 15 bits" to something more complicated in the meantime ( -> $1000f) !?

Harley
08-31-2007, 01:32 PM
deSilva,

Two different values have been used as a mask; $0001_FFFF and $0001_000F. By that I mean the upper or high 15 bits are ZEROs.

The first was the intended value to be ultimately used. The latter was used to attempt to isolate a potential problem at one time.

Sorry if my words made the story muddy.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

Kaio
08-31-2007, 05:24 PM
Harley,

there is a misunderstanding in the readme of POD that I have noticed after your reply.

By default POD is configured to use Ariba's PropTerminal. So all what you need is the serial connection to your Prop and a free Cog. In a second way you could also use POD with keyboard and TV connected at your Prop.

So I would suggest to give it a try. You will see that it is much helpfully for assembly debugging as other options.

Thomas

Harley
08-31-2007, 11:06 PM
Kaio said...
Harley,
there is a misunderstanding in the readme of POD that I have noticed after your reply.
By default POD is configured to use Ariba's PropTerminal. So all what you need is the serial connection to your Prop and a free Cog. In a second way you could also use POD with keyboard and TV connected at your Prop.
So I would suggest to give it a try. You will see that it is much helpfully for assembly debugging as other options.
Thomas

Well, it still seems my configuration excludes being able to use POD.

I have two Props. Prop1 has a serial i/f with a keypad/LED display board and a TV i/f for debugging purposes. Prop2 has no serial i/f except for the PropPlug header, and has NO TV i/f, and this is the one I'm having the WAITPEQ problem with.

Is there a possibility POD could work without extensive modifications to the pcb these two Props and some 20 other ICs reside on?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

deSilva
09-01-2007, 12:00 AM
Harley said...
Sorry if my words made the story muddy.

No, not at all! But I know the situation where you try-out things and you run in cycles because you lost a stable basis...

My suspicion was (and still is http://forums.parallax.com/images/smilies/smile.gif ) that you use check values (from the HUB) which contain bits outside the BAbusMask - this will not work unless you re-activate the AND...

I am comming back to this, as it had been a former misunderstanding with me of how the mask of WAITPEQ works..

I really cannot see another issue with your program.
If a suspicion goes into the more "electrical" scope, then I should suggest pull-ups....

Post Edited (deSilva) : 8/31/2007 10:17:56 PM GMT

Kaio
09-01-2007, 05:08 AM
Harley,

it's all perfect, you could be use POD without any modification of your PCB. Your Prop2 http://forums.parallax.com/images/smilies/wink.gif has all what you need to use POD for debugging your code. You can use the default serial connection (P30/31) of the Prop for POD simultaneously with the Prop Tool.

Here's a short instruction how you should start using POD.
When you have both tools started minimize the PropTerminal. This allows you to use the COM port with the Prop Tool. To show the POD demo open the file PropDebugger.spin with the Prop Tool and hit F10 to load the demo in the RAM of your Prop board. Then restore window of PropTerminal and you will see the output of POD. Make sure that you have set the right COM port before in PropTerminal. I would recommend to save the settings of PropTerminal via File menu after you have it set.

If you want to debug your own assembly code use the file AsmDebug.spin as template which contains the required debug kernel. Then insert your code at the appropriate locations. The comments will help you to find it. Then change in PropDebugger.spin the filename for asmdbg in object section to yours and hit F10 to load it in the RAM of your Prop board. Don't forget to minimize PropTerminal before.

Thomas