Reply by jetmarc September 28, 20042004-09-28
> 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.
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 by dmm September 25, 20042004-09-25
On Sat, 25 Sep 2004 11:35:24 +0200, Andreas <somewhere@else.com> wrote:

>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
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 http://elm-chan.org/works/cmc/report.html
Reply by Ian Bell September 25, 20042004-09-25
Andreas wrote:
> Ian Bell wrote: > >> 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? > > > 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.
Is this bit banged serial - I cannot see a UART in the data sheet?
> >> >>> >>>> Second how is the capaictance measured? >>> >>> >>> >>> >>> 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. >> >> >> >> 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?
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.
>
> > Right.
-- Ian Bell
Reply by Andreas September 25, 20042004-09-25
Ian Bell wrote:

> 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?
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.
> >> >>> Second how is the capaictance measured? >> >> >> >> 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. > > > 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?
Right.
Reply by Ian Bell September 25, 20042004-09-25
Andreas wrote:
> Hi Ian! > >> More info needed to help you properly. First how much data goes >> up/down the TX/RX bus connection and how often? > > > Let's say 1200 bit/s, communication one time per second.
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?
> >> Second how is the capaictance measured? > > > 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.
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?
> > Andreas
-- Ian Bell
Reply by CBFalconer September 25, 20042004-09-25
Andreas wrote:
> > 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.
... 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 "Ask any boat owner the eventual result of continuing the present course indefinitely" - C.B. Falconer, 2004-09-20
Reply by Gene S. Berkowitz September 25, 20042004-09-25
In article <cj3q1m$2pn$03$1@news.t-online.com>, somewhere@else.com 
says...
> Hi Ian! > > > More info needed to help you properly. First how much data goes up/down > > the TX/RX bus connection and how often? > > Let's say 1200 bit/s, communication one time per second. > > > Second how is the capaictance measured? > > 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 >
..how many bytes received, and how quickly must you respond to the transmission before you are in error? --Gene
Reply by Andreas September 25, 20042004-09-25
Hi Ian!

> More info needed to help you properly. First how much data goes up/down > the TX/RX bus connection and how often?
Let's say 1200 bit/s, communication one time per second.
> Second how is the capaictance measured?
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 by Ian Bell September 25, 20042004-09-25
Andreas wrote:
> 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
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 by Andreas September 25, 20042004-09-25
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