C8051F970 CSLIB Capsense Gain Settings At Run Time
04/102/2019 | 07:27 AM
We currently have a customer using a C8051F970 Capsense module. Currently the firmware we supply to the customer allows them to control sensitivity, and thresholds to match their device and sensors.
In some cases we find we need to alter the Hardcoded Capsense gain.
Is it possible to change this at run time. If I try to change the variables in a function, the compiler returns an error indicating it is read only.
Or more precisely modifiable lvalue.
Discussion Forums
8-bit MCUs
Answered
Answered
You wrote:
In some cases we find we need to alter the Hardcoded Capsense gain.
Is it possible to change this at run time.
Do you mind to let us know under what condition and why you need to change the gain on the fly?
based on below code comment in file hardware_routines.c it looks you should not change this on the fly (called by the library).
/**************************************************************************//**
* Ready CS0 for active mode, unbound sensor scanning
*
* This is a top-level function that assumes there is a sensor node struct
* with CS0-related controls. This is called by the library to execute
* one scan of one sensor node. Note that the sensor output is returned
* and not saved to buffers in this routine. Saving is the responsibility
* of the library routines.
*
*****************************************************************************/
uint16_t CSLIB_scanSensorCB(uint8_t nodeIndex)
{
uint16_t ret_val;
setMux(CSLIB_muxValues[nodeIndex]);
setGain(CSLIB_gainValues[nodeIndex]);
// If baseline = 0, no scans have happened and we must be in baseline
// initialization routine. If baseline is non-zero, then we are
// already initialized
if (CSLIB_node[nodeIndex].currentBaseline != 0)
{
setAccumulation(CSLIB_accumulationValues[nodeIndex]);
}
else
{
0
Badly phrased.
At the moment, I would expect to change the gain in code, hardcoded gain.
The customer is experimenting with different sensors, which are likely to require different gains. Normally we would test the sensors ourselves, and provide the firmware with the appropriate gain for the sensor.
One aim was to allow the customer to set the gain via a serial port command, the gain would be stored in flash and set each time the device was booted.
If it is not possible to change the gain via an API or just by writing to a memory location, it just means we may have to send multiple binaries each with a different gain setting.
0
I think the CPT product allow you customize the gain for each sensor (channel), but you need change this in compiling time for C8051F970.
0
The hardware_routines.c file has a setGain( gain) API. This sets the appropriate gain register.
So in the application, the register can be set at runtime, so there shouldn't be a problem setting the gain at run time, between capacitance reads.
C8051F970 CSLIB Capsense Gain Settings At Run Time
We currently have a customer using a C8051F970 Capsense module. Currently the firmware we supply to the customer allows them to control sensitivity, and thresholds to match their device and sensors.
In some cases we find we need to alter the Hardcoded Capsense gain.
At the moment this is set at start up.
Is it possible to change this at run time. If I try to change the variables in a function, the compiler returns an error indicating it is read only.
Or more precisely modifiable lvalue.
You wrote:
Do you mind to let us know under what condition and why you need to change the gain on the fly?
based on below code comment in file hardware_routines.c it looks you should not change this on the fly (called by the library).
Badly phrased.
At the moment, I would expect to change the gain in code, hardcoded gain.
The customer is experimenting with different sensors, which are likely to require different gains. Normally we would test the sensors ourselves, and provide the firmware with the appropriate gain for the sensor.
One aim was to allow the customer to set the gain via a serial port command, the gain would be stored in flash and set each time the device was booted.
If it is not possible to change the gain via an API or just by writing to a memory location, it just means we may have to send multiple binaries each with a different gain setting.
The hardware_routines.c file has a setGain( gain) API. This sets the appropriate gain register.
So in the application, the register can be set at runtime, so there shouldn't be a problem setting the gain at run time, between capacitance reads.