2007-02-11 01:19 AM
2011-05-17 12:36 AM
When use P9 as output port, should init the GPIO9 as follows
GPIO_DeInit(GPIO9); GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_Alternate=GPIO_OutputAlt1; GPIO_Init (GPIO9, &GPIO_InitStructure); if run this program step by step, we will find that: SCU->GPIOOUT[GPIO_Number]=?? // GPIO_Number is 9 !! But the range of SCU->GPIOOUT[] is 0..7, SCU->GPIOOUT[8] and SCU->GPIOOUT[9] are not exist!! I think should add the (1) statment in GPIO_Init function. /**********************************************/ void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct) { /* Select pin direction */ u8 PinNumber = 0; u8 Counter = 0; u8 GPIO_Number = 0; GPIO_Number = GPIO_GetGPIONumber(GPIOx); if(GPIO_InitStruct->GPIO_Direction == GPIO_PinOutput) { GPIOx->DDR |= GPIO_InitStruct->GPIO_Pin; } else { GPIOx->DDR &= ~GPIO_InitStruct->GPIO_Pin; } for (Counter = 0; Counter < 8;Counter++) { /*Search pin number*/ PinNumber = (GPIO_InitStruct->GPIO_Pin & (1 < if((PinNumber >> Counter) == 1) { if (GPIO_Number { /*Output ALternate 0*/ SCU->GPIOOUT[GPIO_Number] &= ~(0x3 < if(GPIO_InitStruct->GPIO_Alternate == GPIO_OutputAlt1) { /*Output ALternate 1*/ SCU->GPIOOUT[GPIO_Number] |= 1 << (Counter *2); // (2) } if(GPIO_InitStruct->GPIO_Alternate == GPIO_OutputAlt2) { /*Output ALternate 2*/ SCU->GPIOOUT[GPIO_Number] |= 0x2 << (Counter *2); } if(GPIO_InitStruct->GPIO_Alternate == GPIO_OutputAlt3) { /*Output ALternate 3*/ SCU->GPIOOUT[GPIO_Number] |= 0x3 << (Counter *2); } } /*Type configuration: PushPull or Open Collector*/ SCU->GPIOTYPE[GPIO_Number] &= ~(0x1 << Counter) ; if(GPIO_InitStruct->GPIO_Type == GPIO_Type_OpenCollector) { /*Open Drain configuration*/ SCU->GPIOTYPE[GPIO_Number] |= 0x1 << Counter; } /*IP Connected disable*/ SCU->GPIOIN[GPIO_Number] &= ~(0x1 << Counter) ; if(GPIO_InitStruct->GPIO_IPConnected == GPIO_IPConnected_Enable) { /*IP Connected enable*/ SCU->GPIOIN[GPIO_Number] |= 0x1 << Counter; } } } } [ This message was edited by: seawwh on 07-02-2007 16:06 ] [ This message was edited by: seawwh on 11-02-2007 09:33 ]2011-05-17 12:36 AM
Hi seawwh,
This error will be corrected in the next release v1.2 of the library which will be available next month. Thank you and best regards, mirou2011-05-17 12:36 AM
Hi seawwh,
many thanks for having found this bug. I have been trying to use the I2C peripheral of my mcu for weeks, but without success. I use the STR912FW44 and on this mcu, the I2C interfaces are located on port 2. I was using ports 8 and 9 at the same time, and because of this bug, I2C would not work :( Your post just gave me the missing hint... Thanks a lot.