Measuring the cheap meter on my desk, the 10A range uses a 0.1 ohm shunt resistor and the 400 mA range uses a 2.5 ohm shunt resistor and the 4mA range uses a 100 ohm shunt resistor.
100 mA through 0.1 ohms is 10 mV drop and 100 mA though 2.5 ohms is 250 mV drop. So depending on the impedance of your circuit, the current could be lower in the lower range just because of the increased series resistance.
You can measure the voltage drop across the ammeter with another voltmeter.
When you can't tolerate voltage drop, try a feedback ammeter: http://www.keithley.com/data?asset=6169
Every RTOS for a PIC which does not have a software-addressable stack generally requires that all but one of the tasks must have its work divided into uninterruptable pieces which begin and end at the top stack level; the "task-yield" operation does not use a function call, but rather a sequence like
// This code is part of task C (assume for this example, there are tasks
// called A, B, C
movlw JumpC4 & 255
goto TASK_SWITCH_FROM_C
TargetC4:
Elsewhere in the code would be some code like:
TASK_SWITCH_FROM_A:
movwf nextJumpA // Save state of task C
// Now dispatch next instruction for task A
movlw TaskB_Table >> 8
movwf PCLATH
movf nextJumpB,w
movwf PCL
TASK_SWITCH_FROM_B:
movwf nextJumpB // Save state of task C
// Now dispatch next instruction for task A
movlw TaskC_Table >> 8
movwf PCLATH
movf nextJumpC,w
movwf PCL
TASK_SWITCH_FROM_C:
movwf nextJumpC // Save state of task C
// Now dispatch next instruction for task A
movlw TaskA_Table >> 8
movwf PCLATH
movf nextJumpA,w
movwf PCL
At the end of the code, for each task, there would be a jump table; each table would have to fit within a 256-word page (and could thus have a maximum of 256 jumps)
TaskC_Table:
JumpC0 : goto TargetC0
JumpC1 : goto TargetC1
JumpC2 : goto TargetC2
JumpC3 : goto TargetC3
JumpC4 : goto TargetC4
...etc.
Effectively, the movlw
at the start of the task-switch sequence loads the W register with the LSB of the address of the instruction at JumpC4
. The code at TASK_SWITCH_FROM_C
would stash that value someplace, and then dispatch the code for task A. Later, after TASK_SWITCH_FROM_B
is executed, the stored JumpC4
address would be reloaded into W and the system would jump to the instruction pointed to thereby. That instruction would be a goto TargetC4
, which would in turn resume execution at the instruction following the task-switch sequence. Note that task switching doesn't use the stack at all.
If one wanted to do a task switch within a called function, it might be possible to do so if that function's call and return were handled in a manner similar to the above (one would probably have to wrap the function call in a special macro to force the proper code to be generated). Note that the compiler itself wouldn't be capable of generating code like the above. Instead, macros in the source code would generate directives in the assembly-language file. A program supplied by the RTOS vendor would read the assembly-language file, look for those directives, and generate the appropriate vectoring code.
Best Answer
You don't give a number for the maximum delay you require, or much description of the design, but I'm assuming it's to be an autoranging/switching type of meter.
There are plenty of cheap analogue multplexers available, the best known being the 74xx4051, 4052 and 4053 series.
These are dual polarity 8:1 (4051), 2 x 4:1 (4052), and 4 x 2:1 (4053) muxes, available for under 50 cents and made by various manufacturers (e.g. TI, AD, Maxim, etc) I would have a look at these and similar offerings. Here is an example 4051 part from Farnell (many more here). Also see analogue switches.
For slower switching only one or two ways, but better isolation and lower resistance there are mechanical relays (or solid state relays, such as the PhotoMOS type from Clare) These can be used where appropriate, together with IC switches, e.g. to isolate one channel from the next when active.