Very simple multitasking on MSP430

Hi! I have to program a MSP430F11(0/1)1 (1/2KB Flash, 128B RAM) to do 2 tasks:

- RX/TX bus connection

- measure a capacitance with timer_A

The measurement has to run every certain time. But this has not the highest priority. It is better for me to loose one measurement cycle and therefore get incoming bus data. At this point I remark, that I can't adjust interrupt priorities in the MSP430, they are built in. The RX function can be implemented blocking (waiting for an interrupt to occur) or non-blocking (by waiting for an interrupt OR a timeout). How can the tasks be arranged to work pseudo-simultanous? I know the simple OS versions available for the MSP430, but they need too much memory. I tried to use 16-bit watchdog as an interval timer to get a system time source. Its interrupt has the highest priority, hasn't it? Now I need a very very simple scheduler.

I thought about this, too: In this scenario I use the watchdog timer in reset mode as task timer. I have a reset-persistent RAM area, where I can hold status variables over a reset. So I can use a state variable (measure/RXTX) and switch to the corresponding next action after a reset. If the task time is used up, I get a reset by the watchdog timer, switch to the other task by asking my state variable and so on. So I have a reset context switch ;-)

What do you think?

Regards, Andreas

Reply to
Andreas
Loading thread data ...

More info needed to help you properly. First how much data goes up/down the TX/RX bus connection and how often? Second how is the capaictance measured? With something as simple as this it should only be necessary to manage the interrupts properly and use a simple background routine to hold things together.

Ian

--
Ian Bell
Reply to
Ian Bell

Hi Ian!

Let's say 1200 bit/s, communication one time per second.

Comparator triggers timer if a certain charge value of the cap. is reached. The time for the charge interval is measured and a value for the given cap.

Andreas

Reply to
Andreas

..how many bytes received, and how quickly must you respond to the transmission before you are in error?

--Gene

Reply to
Gene S. Berkowitz

... snip ...

Sounds much too complicated for such a simple task. First you need some details on the individual tasks, such as baud rate for the RX/TX system, inter-measurement period, precisions required and corresponding timing accuracy, etc. Sounds as if a single PIC could do the job.

--
 "It is not a question of staying the course, but of changing
  the course"                        - John Kerry, 2004-09-20
 Click to see the full signature
Reply to
CBFalconer

OK, just a little more clarification needed now.

Is the data sent/received as bits or bytes and how much in each direction and at what speed?

I assume this means you discharge the cap then connect it to a constant current source and sart the timer. When the comparator triggers you stop and/or read the timer to get the value of the cap, correct?

--
Ian Bell
Reply to
Ian Bell

Serial bitwise. One packet is 6 bytes. After a packet sent/receive I have time to do other things. There is a master initiating each transmision with its slaves. The question I asked is in relation to the slaves. The master has more ressources.

Right.

Reply to
Andreas

Is this bit banged serial - I cannot see a UART in the data sheet?

How often is cap meausred and what a max and min intervals corresponding to range of caps?

Sorry for all the questions but they are important.

--
Ian Bell
Reply to
Ian Bell

Perhaps you can obtain a few ideas by this design. A Japanese gentleman has created a capacitance meter using the comparator of an AT90S2313, then sends a serial output to a LED display.

The circuit and source code is available at

formatting link

Reply to
dmm

You could use an interrupt function for the bus data. This ensures that it has highest priority.

For the measurement, you could program the timer, but disable its interrupt. So it wont get into the way of the bus data. Instead, you poll the flag bit in your main loop. Once the timer flags, you detect it shortly after (unless there is bus data activity) and do the proper reaction within your main loop.

Regards, Marc

Reply to
jetmarc

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.