Main Site Documentation

ADC channel 9


#1

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


#2

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:


#3

http://wiki.tinyclr.com/index.php?title=FEZ_Cerberus_Developer#Non-Gadgeteer_Code_Examples_until_Gadgeteer_is_released_for_4.2


#4

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


#5

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.


#6

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


#7

Why can’t the enums be changed?


#8

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


#9

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.


#10

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.


#11

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