2017-07-17 03:37 AM
Hey
I'm using stm32f103c8 and I want to use all of the GPIOB .it work good expect pin 3 and 4.Those pin use for sys_njtrst and sys_jtdo-tracswo but i just use SW and i don't need these pins for programming and want to use for other purpose but its not work.can i do that?is it possible to use for input or output purpose?
Solved! Go to Solution.
2017-07-22 01:16 AM
Thanks
2017-07-17 04:01 AM
Hello!
You must remap theese pin's function by use AF
for example
GPIO_InitTypeDef GPIO_InitStruct;
//GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
//GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Mode = GPIO_MODE_AF_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
GPIO_InitStruct.Pin = GPIO_PIN_2;
HAL_GPIO_Init(GPIO_B, &GPIO_InitStruct);�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
�?
2017-07-17 06:18 AM
hey thanks for your help.
can you explain more?Because it's not work
2017-07-17 09:12 AM
Hello again
what you mean when you say 'is not work'?
I suppose that you use HAL drivers.
A very simple example for PB3 as push-pull GPIO Output:
//initialisation
__HAL_RCC_GPIOB_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Pin = GPIO_PIN_3;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);�?�?�?�?�?�?
�?�?�?�?�?�?�?
After initialize it you can use it as output :
//Set output level
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET);// Output is HI�?�?
or
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET);// Output is Low �?
Read also the STM32F103x8 DataSheet for details about pins and remaps of functions.
2017-07-17 11:06 PM
hello
♯ define WS2812B_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3|GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7|GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11|GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15)
GPIO_InitStructure.GPIO_Pin = WS2812B_PINS;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStructure);DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&WS2812B_PORT->ODR;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)framedata; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_BufferSize = BUFFER_SIZE; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel5, &DMA_InitStructure);This is my code for config gpio AND I use DMA .all of pin work well expect
GPIO_Pin_3|GPIO_Pin_4.
can you tell me what's wrong in my code?
thanks
2017-07-18 12:48 AM
Hello!
After GPIO_Init function add
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
2017-07-22 01:16 AM
Thanks