2013-05-24 03:12 PM
Hello!
I'm new to micro controller programming. I have been told to ''poll a pin'' and perform a specific action if this pin ''goes low''. So I wrote this code to ''poll'' a PD10 pin on my board:GPIO_InitTypeDef portd;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
portd.GPIO_Mode = GPIO_Mode_IN;
portd.GPIO_PuPd = GPIO_PuPd_NOPULL;
portd.GPIO_Pin = GPIO_Pin_10;
GPIO_Init(GPIOD, &portd);
Next I do this in an endless loop:
uint8_t pd10 = GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_10);
if
(pd10 == 0){
//1=high 0=low
//Perform an action when PD10 goes low
}
I got it right?
PS STM32F3-Discovery board.
2013-05-24 04:41 PM
At first glance it doesn't appear unreasonable. What are you doing to make the pin attain a high and low state?
I you have a button that connects to ground, the other side should have a pull-up.2013-05-24 06:35 PM
I'm trying to read data from the AD7738 ADC atm.
So I need to:1)Configure the SPI2)Write some cfg data to ADC registers3)Check the RDY pin state and send some byte through SPI.(full sequence I found here: http://ez.analog.com/thread/16829)I did all the configuration task but the RDY pin (PD10) stays high from the very beginning (even before the whole configuration executed) and it does not go low. Its OK for the pin to be high all time? It is high even when I do not attach any wire to it. I'm confused.If necessary I can show my code for the SPI configuration.Thank you for your reply.2013-05-25 04:45 PM
Its ok now, problem is solved. I configured the ADC wrong. Now everything works... except the actual converted data :p