I am porting an industrial embedded application to a Windows CE device and require some guidance.
The current application briefly does the following operations.
Constantly reads information from the serial port. At start, data is sent to serial port to initialise serial device.
Sends commands to an LCD screen using proprietary coding via serial type cable.
I have established that the program is broken down into several pieces. The program is written for the Freescale 68331 processor.
1. An interrupt is generated every millisecond, and critical code is run looking at and setting I/O to external field devices.
2. An interrupt is generated each time the UART gets data. This data from the serial device is stored in a queue structure. Program code in the above point looks at this queue and manipulates the queue after reading the data.
3. The main program loop services the screen routines and other less time critical operations.
My thoughts and questions:
I believe I need to use native code rather than managed code. I guess I am not comfortable with garbage collection being out of my control in a real time system, etc. Therefore, I believe VC++ is my only option for my Windows CE application.
I wish to use a GUI. Therefore, using VC++, I would need to manipulate the message pump. I also mentioned above that I need to do serial communications. How does this tie-in with the event driven model? I have seen some serial communication code that runs in a separate thread and sends Windows messages to the message pump on data arrival and other events, but apparently, there is a slight overhead. I don't think this overhead would be all that great.
How would I implement the one millisecond interrupt? Would timers be the best way to go here? The existing code decrements many variables (used as timers) every millisecond as per the interrupt. These timer variables are then set in program code to the number of milliseconds required, before the program code decides what to do when they eventually reach zero. Would this be the best approach? There are a lot of timers needed hence why I thought it be best to decrement some integer values in a one millisecond windows timer. What about IST's? Can you set up an IST in a user-mode program and link this to the ISR for the real-time clock to run every millisecond? I ask the above about setting the IST in the program because I'm wondering where else I would do this, as the code is application specific.
Bear in mind, that the data that comes from the serial device and that is stored in the queue, must be accessible to the code that runs in points 1 and 3 above.
Personally, I would prefer not to use VC++ as I have had not much exposure to it.
Any help would be much appreciated.