ADC channel 9

cerberus code has 9 ADC channels, but only 8 can be accessed using AnalogInput ?

proably I am just so stupid, but i could not write code that access all 9 channels :frowning:

Antti

How are you trying to access channel 9? The Microsoft analog implementation only has up to a max of 8 enumerated analog inputs. Just cast the last input like this:


AnalogInput PA5 = new AnalogInput((Cpu.AnalogChannel)8);

This should work. Welcome to the community. :slight_smile:

to Aron

thanksā€¦ I had the () around 8
hence got compiler error

I started with Turbo Pascal 1.0 for CP/M Z80, well that was after fortran on punched cards and basic on punched tapesā€¦

my bad, feel bad asking so trivial thingā€¦

Antti

Is the issue simply that Cpu.AnalogChannel only has entries from ANALOG_0 to ANALOG_7?

That should be pretty trivial to fixā€¦ we can fix the fact that Cpu.Pin only has GPIO_Pin0 to GPIO_Pin15 at the same time, and we can fix Cpu.PWMChannel as well (the hardware supports at least 16 PWM outputs).

Iā€™m actually playing around right now with the analog stuffā€¦ the STM32 has three ā€œinternalā€ channels, one which allows it to read an internal temperature sensor, one which allows it to read the voltage on the VREF pin, and one which allows it to read the voltage on the VBAT pin. Iā€™m looking to add these as analog ā€œchannelsā€ which can be read via AnalogInput.

there is no 100% fix possible because

NETMF 4.2 ENUMā€™s have limits

ADC 8
PWM 8
GPIO 16

those can not be changedā€¦ :frowning:

Antti

Why canā€™t the enums be changed?

well they are part of SPOT core assemblies and those are maintained by
MS or netmf.codeplex.com peopleā€¦

so you would need to talk to THEM to make this change happeningā€¦

what is much worse thing, is that i2c bus is limited to one in SPOT :frowning:

Antti

If it actually came to that, we could maintain a set of patches to be applied to the codebase, if the NETMF core team wasnā€™t interested. I donā€™t know why the wouldnā€™t be, though, if we asked nicely :slight_smile:

Are you building with the stm32f4xx.h header, or the stm32f1xx.h header as released by Oberon and modified by GHI? It seems like a lot of this work would be a lot simpler if we/I could use the values in that header without having to check and correct each one.

It should be possible to do for I2C what was done with SPI, and introduce the concept of an I2C ā€œmoduleā€ that can be independently chosen.

Itā€™s less critical than for SPI, however, as I2C natively supports multiple devices on the same bus.

it SHOULD be yes, exactly, same as for COM and SPI, I2C bus should also have multiply instances if desired. This is much more critical issue for NETMF 4.2a then increasing ANALOG_x enum range

Antti