Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:42 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Maximite Interrupts

Author Message
wizged
Newbie

Joined: 05/02/2013
Location: Australia
Posts: 13
Posted: 12:31am 05 Feb 2013
Copy link to clipboard 
Print this post

Hi all,

I've had my Maximite for a few months now but have only recently started my first real project with it. Unfortunately I have a strange problem with interrupts and I'm hoping someone might have a clue what's going on. I'm running MMBasic v4.3 but had the same issue on v4.1

I'm trying to use the Maximite to communicate with an 8-bit parallel Z80 PIO port in a Microbee. I'm using 10 pins for this (11-20), 8 of which are for the data and 2 for handshaking. I have data moving OK from Microbee to Maximite, but have handshaking issues trying to shift it in the other direction.

When sending data to the PIO the first handshaking pin is used to signal the PIO that the Maximite has a byte ready on the port to process. The PIO then uses the second pin to signal the Maximite that its done and is ready for the next byte. I have an interrupt set on the second pin which I use to clear a "don't send any more data until the PIO is ready" flag.

The scheme seems to work fine for a random number of transmitted bytes (anywhere from 10 to 150 or so) but then it stops because the Maximite doesn't seem to detect (or maybe doesn't process) the handshaking interrupt and so doesn't clear the "don't send any more data" flag. I can see that the PIO is definitely generating the right handshaking signal (using a DSO) but somehow the Maximite is missing it. The problematic signal is a pulse from high to low lasting about 20uS.

Is it possible that this pulse is too short for reliable interrupt operation? Or maybe the Maximite internally disables interrupts from time to time? (I'm not using the INPUT statement anywhere). Or, more likely, I'm just missing something important.

Any thoughts anyone? (apologies for the excessively long first post BTW )



 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 02:59am 05 Feb 2013
Copy link to clipboard 
Print this post

The interrupts used by MMBasic are not hardware interrupts. They are implemented by the interpreter which checks the status of the interrupting pin after each BASIC command is executed. Executing a BASIC command typically takes about 35uS so the interpreter does the check every 35uS (on average). However some commands can take a lot longer so your pulse width should be 80uS or even 100uS for reliable operation.

One way around this might be to use a counting input. These do use a hardware interrupt (this is why there are just four of them). You could configure the input as a counting input (which resets the count to zero) and then periodically poll to see if the count has advanced to one. One issue with this is that they only count on a positive leading edge. If your strobe is negative going you will be out of luck.

One point should be made - all interpreters are inherently slow and therefore will have difficulty with high speed I/O. You might need to think about writing a specialised C function for your task and add that to MMBasic. That would require downloading the source and recompiling with your function added - a steep learning curve!

Geoff
Geoff Graham - http://geoffg.net
 
wizged
Newbie

Joined: 05/02/2013
Location: Australia
Posts: 13
Posted: 10:41pm 05 Feb 2013
Copy link to clipboard 
Print this post

Thanks Geoff, that explains it perfectly

The counter idea sounds good to me so I'll give that a go. I can't see any problem with adjusting my logic to cater for a positive leading edge count

I'm not particularly concerned about the interpreter speed as I suspect the Maximite will probably outpace the Microbee's ability to receive and deal with the data anyway. It will be an interesting test actually as they are quite similar systems on the surface, just 30 years apart in technology

Anyway, thanks for your help on this - very much appreciated
 
wizged
Newbie

Joined: 05/02/2013
Location: Australia
Posts: 13
Posted: 12:02am 12 Feb 2013
Copy link to clipboard 
Print this post

Changing to a counting input has solved my PIO handshaking problem and data transfers are now working fine

On the performance side it looks like I was wrong - the Microbee is more than capable of keeping up with the Maximite in this case. I have the Microbee running a simple machine language program to receive data from the Maximite and load it into a sequential memory block. End to end transfer rate is currently about 1KB/s, or about 1ms per byte. Nearly all of that 1ms is consumed by processing on the Maximite side in reading the byte from SD, preparing it for transfer, PIO handshaking etc. Once the Microbee sees the byte available on the PIO it can read and deal with it in just 10uS or so

Obviously its not really a fair comparison when I have a simple machine language program on one side and considerably more complex interpreted Basic reading SD data on the other, but an interesting exercise from my perspective anyway. The transfer speed I'm getting is fine for this project so I can now happily move on to the next stage

 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024