Thanks Knut.
I am reading the data sheet and the code is starting to make sense now.
In my case I need to convert a single-ended input, not a differential input.
As far as I understand it, I need to set the multiplex register to 8, which means selecting:
0000 (AIN0) 1000 (AINCOM)
I am not sure if I have got this right.
BTW, there is no AINCOM pin on the board, which makes me think that it is tied to some reference.
With the code as it is now, I get very unstable readings.
Here's an example of readings with AIN0 put to VCC (5V in my case):
16777198
16776701
16777200
0
0
16777200
16777200
16777199
16777202
16776701
16776701
16777200
16777200
0
8388608
16776701
16777198
0
8388608
any suggestion is more than welcome!