2011-09-16 05:43 AM
Hi everybody,
i want to define an pin of my STM32F103ZE as input with an pull-down. I read in the documentation that i have to set in the CRH register CNF1 = 1, CNF0 = 0, Mode1 = Mode0 = 0 and the PxODR = 0. But what is this PxODR register? I havent found any informations about it. Is it similar like the ODR register a 32bit register, where only the first 16bits can be written? So that each bit stands of one pin? Hope you can help me! regards2011-09-16 10:30 AM
The CR uses 4-bits per port, the ODR uses 1-bit per port. Consequently the CR requires 64-bits to configure 16 IO's, and does this by splitting it into two 32-bit registers CRL, CRH
xODR, where x is A..G depending on the GPIO bank we're talking about. It normally defines the direction of the output, but in Input Pull Up/Down it defines the Up or Down part. You can also use BRR or BSRR to achieve the setting of ODR too. If you have to program the part at a bit level you need to be able read and interpret Reference Manuals, and Library Source, for yourself. Alternately you can paste in a library call, and let it deal with the minutia : GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; GPIO_Init(GPIOE, &GPIO_InitStructure);2011-09-23 07:54 AM
Hi,
Use standard library for any type of peripheral and pins initialization. It works just fine.regards2011-09-23 09:22 AM
Use standard library for any type of peripheral and pins initialization. It works just fine.
Forum Observations: Users with the most experience use the library to develop quickly, robustly, and portably. They can debug the few bugs that might exist in the library. Can change pins and parts in a couple of minutes. If space is really tight they'd use a table driven mechanism to configure the pins, or fold multiple/maximal pin per library call. Finally if they just need to touch one register they can call it out explicitly ie ''Usart->DR = 0x23;'', which will in fact compile very efficiently. Users with the least experience, or hard-core 8-bit mentality, insist on banging register bits, fail to fully digest the documentation and register minutia, miss initial conditions, and can't debug the mess they have created. No offense to anyone, but just think about it before you bury man-days of debugging effort to fix the one bit you overlooked, while your boss steams about the project deadline.