register values

Feb 8, 2021 at 6:25pm
Ok so, I want to access this within C++:

R0xAF[0] = 0.


I can set it to 0xAF with no [brackets] but then I lose the bracketed results (i.e. 0xAF[1] and 0xAF[2]. How can I access 0xAF[1]?
Feb 8, 2021 at 6:33pm
Show what you've tried.
Feb 8, 2021 at 8:10pm
This writes a 0 to the Automatic Exposure Control register (175), turning it off:
 
ArduCam_writeSensorReg(cameraHandle, 175, 0);

Works fine.

Another way:
1
2
3
AGC is disabled (R0xAF[1] = 0), 
AEC is disabled by: (R0xAF[0] = 0),
But can't use this format, compiler error. 

1
2
R0xAF[1] = 0 
R0xAF[0] =0

How are AGC control and AEC turned on in this matter?

I'm missing something really simple.
Last edited on Feb 8, 2021 at 8:14pm
Feb 8, 2021 at 8:48pm
Did you really expect people to understand what you were talking about from your first post?

I don't think that notation is C++ array notation. It's just a way of referring to registers in the device.
You have a function that allows you to write to a sensor register (in your case register 0xAF (175)).
But you would like to be able to write to specific bits (maybe?).
How about:

1
2
// Enable AGC, disable AEC
ArduCam_writeSensorReg(cameraHandle, 0xAF, 0b10); // set bit 1 to 1, all other bits to 0 

If I'm right about that array-like notation referring to bits then you could set/reset those specific bits while leaving other bits in the register unchanged like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
void enable_aec(ArduCamHandle cam)
{
    unsigned long val;
    ArduCam_readSensorReg(cam, 0xAF, &val);
    ArduCam_writeSensorReg(cam, 0xAF, val | 1ul);
}

void disable_aec(ArduCamHandle cam)
{
    unsigned long val;
    ArduCam_readSensorReg(cam, 0xAF, &val);
    ArduCam_writeSensorReg(cam, 0xAF, val & ~1ul);
}

void enable_agc(ArduCamHandle cam)
{
    unsigned long val;
    ArduCam_readSensorReg(cam, 0xAF, &val);
    ArduCam_writeSensorReg(cam, 0xAF, val | 2ul);
}

void disable_agc(ArduCamHandle cam)
{
    unsigned long val;
    ArduCam_readSensorReg(cam, 0xAF, &val);
    ArduCam_writeSensorReg(cam, 0xAF, val & ~2ul);
}

If any of the ArduCam_... functions return non-zero, it indicates an error. You might want to check that.
Last edited on Feb 8, 2021 at 9:08pm
Topic archived. No new replies allowed.