Interrupts are delayed until after wait* instructions complete?
DavidZemon
Posts: 2,973
in Propeller 2
I'm trying to wrap my head around this constraint. I'd like to write a program that does something in a software loop on a periodic basis (blinking an LED is fine for my example) and also transmits data out a serial port. I'd like to use a smart pin to do that transmission, and I'd like to buffer the data into an array that is emptied via WYPIN in an interrupt to produce a constant stream of serial data.
But I normally write software loops for outputting to LEDs like so:
Well that's no good, is it? Now I'm going to have a big gap between each byte of my serial transmission because I have to wait for the waitx instruction to complete before the next byte can be loaded. Is there a special instruction that I'm missing which allows me to do this better? My best idea right now is to write a new function "interruptable_wait()" that does multiple waitx instructions in a loop, allowing interrupts to happen in the middle, or maybe even just does a "while(CT != value);" but that just makes me cry tears of inefficiency.
But I normally write software loops for outputting to LEDs like so:
while (1) { drive_invert(58); // Executes a drvnot instruction waitx(CLOCK_FREQ / 20); }
Well that's no good, is it? Now I'm going to have a big gap between each byte of my serial transmission because I have to wait for the waitx instruction to complete before the next byte can be loaded. Is there a special instruction that I'm missing which allows me to do this better? My best idea right now is to write a new function "interruptable_wait()" that does multiple waitx instructions in a loop, allowing interrupts to happen in the middle, or maybe even just does a "while(CT != value);" but that just makes me cry tears of inefficiency.
Comments
Instructions are basically atomic. Interrupts happen once one is complete.
Maybe you can get some work done in a loop?
Use one of them instead of WAITX with POLLCTx.
So... I'm starting to feel really dumb. Almost every single thing I've tried to do with this chip has not worked the first time around. I can't even get a simple program working that use pollct1 or jnct1.
The instruction sheet says
So if I pre-load a register with "getct timer", I should be able to do "addct1 timer, period" to set up the event, right?
But, this isn't working.
I finally commented out the addct1 and wham it started working. It was what the hell? Only then did I look at the timer variable that addct1 operates on. It should be long 0.
Try this instead
I had that at one point... I removed it when I started using "getct timer" because I thought getct would override whatever value was in timer prior to the instruction and that the "0" after "timer long" was just an optional initial value. Is it not?
That is definitely the behavior I was seeing. And, sorry about asking the second dumb question :P when I typed up that reply, all I could see was evan's first response. Browser oddity? Blind user? Who knows...