Hello, I'm using Keil MCBSTM32 evaluation board and µVision3. I use the example CAN program downloaded from keil. My application will be to use an external rotational transducer (instead of the potentiometer on the board) to send converted analog value in CAN message. Which code should i change/add so that i could use the transducer (at port A chan 0 for example) instead PA ch 1 of the pot? I've read the reference manual from ST but i didn't see any indication telling which registers correspond to which channel to use. Thank you in advance.
Hello Ferris Adna,
to use PA0 instead of PA1 change the code as follows:
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN; // enable periperal clock for ADC1 ADC1->SQR1 &= ~0x00F00000; // only one conversion ADC1->SMPR2 &= ~0x00000007; // clear bits 0..1 (channel0) ADC1->SMPR2 |= 0x00000005; // sample time (55,5 cycles) ADC1->SQR3 = 0x00000000; // set channl0 for 1st conversion ADC1->CR1 = 0x00000100; // use independant mode, SCAN mode ADC1->CR2 = 0x000E0003; // data align right, cont conversion // EXTSEL = SWSTART // enable ADC, no external Trigger ADC1->CR2 |= 0x00500000; // start SW conversion
Best Regards, Martin Guenther
Thank you Reinhard Keil and Martin Gunther for your reply.
The link does help a lot.
Thanks Martin for the codes to use PA0 instead of PA1. I did that too and it worked.