Hi, > As I understand it, the amforth way of dealing with interrupts on the > serial port is to have the ISR set a flag, and the uart is truly > serviced when the inner interpreter steps to the next word.
You are right that the inner interpreter can deal with interrupts (to some extent), but the usart communication for the command interpreter does not use it. The reason is simple: I initially wrote it in assembly language. I tried to redesign it to use the forth interrupts, but never really succeeded for many and varying reason... The interrupts amforth can handle with the current inner interpreter hook are restricted to _not_ require any hardware access during the interrupts. That means: if an interrupt is triggered and needs to be cleared by reading some special address (e.g. reading the received character from the USART data register), that read operation does not happen. That means, that the interrupt sources does not get cleared and re-fires immedieatly, making the system unusable (looks like a crash). Details are outlines in the docs (somewhere). Serial communication has to aspects: sending and receiving single characters. Sending characters is trivial since the application knows when and what to send. The hardware module does the lowlevel task for the shifting out of the bits and framing etc. This is pure forth code and there is no timing problem (IMHO). Just have a look at the usart-tx-poll.asm file. There is an interrupt based routine as well (usart-tx-isr.asm), but avoid using it. It works but gives no benefit while making the code more complicated. Receiving characters is a completly different thing. The characters can come at any time, therefore the code needs to deal with the situation relativly fast (at least before the next character arrives). The USART receiver can be polled for a character and set a flag if anything is available. The same flag can be used to trigger an interrupt that reads the character and handle it. If the polling is done often enough, it works surprisingly well. This is what the usatz-rx-poll.asm code does. A better solution is usart-rx-isr.asm. This code uses interrupts and an internal ring buffer (16 characters long) to keep the characters. The KEY and KEY? words simply check the length of the (used) ring buffer and extract the characters from it. Matthias ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ Amforth-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/amforth-devel
