COG/LUT exec,streamer and interrupts acting weird [SOLVED]
ozpropdev
Posts: 2,793
Hi Chip
I am experiencing an issue using a lut based isr VGA video driver with cog code.
I assumed that because the LUT is dual port ram the streamer can access lut at the same time as LUT exec does.
This seems to be the case as the driver works nicely and the image is rock solid.
The problem is that a CALL in cog ram to cog ram causes the video driver to fail.
In the included code a PAUSE is done in straight code which works fine.
If that code is replaced with a CALL to identical code the video driver fails.
The CALL'd routine is working correctly and is verified by the LED activity.
Is it simply that the lut based isr video driver shouldn't have worked in the first place?
Have I broken a rule and pushed my luck again?
I am experiencing an issue using a lut based isr VGA video driver with cog code.
I assumed that because the LUT is dual port ram the streamer can access lut at the same time as LUT exec does.
This seems to be the case as the driver works nicely and the image is rock solid.
The problem is that a CALL in cog ram to cog ram causes the video driver to fail.
In the included code a PAUSE is done in straight code which works fine.
If that code is replaced with a CALL to identical code the video driver fails.
The CALL'd routine is working correctly and is verified by the LED activity.
Is it simply that the lut based isr video driver shouldn't have worked in the first place?
Have I broken a rule and pushed my luck again?
Comments
I do get an "Undefined symbol" for variable pb. EDIT: Ah, I see that's meant to be ptrb.
Have you made any new discoveries?
I'm still digging....
I've been really stumped a few times, myself, so far, when writing Prop2 software. Hopefully, we can have good single-stepping tools that let us see where these problems lie, as they've tied me up for half a day, on occasion.
Oh, why did Chip do that? That's overly terse.
If I JMP to the routine and use a JMP instead of a RET to return back the code works.
The CALLPA and CALLPB mnemonics are about as long as they can be. I figured that PA and PB could mean 'pointer' or 'parameter', as they now serve both purposes.
That will jumble up the stack.
I would make the ISR code so that it does each step and then an RESI1, and use variables that only it touches to keep track of counters. The PC can be maintained across interrupts via the RESI1 instructions.
Any CALLs and RETs that you do in your ISR would have to fully RETurn, so as not to corrupt the stack for your mainline code.
If I PUSH a value onto the stack before I make the CALL I can POP the correct value off the stack after the CALL.
But isn't that all punctuated by interrupts that expect stack values to survive between interrupts, while your main code does CALLs, too?
Funny how something can be staring you in the face and you still miss it.
It's clear now, oops!
The streamer locks out hubexec so running the video stuff in LUT frees up cog ram for the main code.
Thanks for setting me straight Chip!
No problem. Glad we know what the trouble was.
How's the new compile looking?
I've got the Prop123_A9 compiled and am waiting on the BeMicro_A9 right now. Once these two are out of the way, the rest go quickly. I've got the doc's updated, except for the serial loader changes. It's in a new file, not the currently-linked one. I really want to get this next release out, because I think it's pretty final.
This added to the whole "what going on?" scenario.
http://forums.parallax.com/discussion/163083/pnut-problem-with-calld-when-calling-from-a-cog-address-to-another-cog-address
The following example moves some code from hub to lut and then uses a CALLD instruction to call lut.
I had to manually encode the LOC and CALLD instructions to get it to work.
I've been looking over the CALLD code in the assembler. There are some problems that I thought I had really delved into recently and tuned up. I will get it fixed soon.
Is the problem i'm having with LOC instruction in the example code above linked to the CALLD problem?
It could be. I remember totally revamping that a week or two ago, but the source code looks like it used to. I might have moved a file the wrong direction, or something. I'm going to Parallax today to get the test chips mounted on the new PCBs and see how they work. I will get back on the assembler code tonight.