2013-01-20 03:35 PM
Hi guys,
I have this question, /* GPIOA Periph clock enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); /* Configure PA0 .. PA7 in output pushpull mode */ GPIO_InitStructure.GPIO_Pin = 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_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Configure PA8 .. PA15 in input, pulled up mode */ GPIO_InitStructure.GPIO_Pin = 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_Mode = GPIO_Mode_IPU; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIOA->ODR = GPIOA->IDR >> 8; // Mirror high ordered inputs to low ordered outputs could you explain to me the bold one especially ''8'' and IDR for example I want to mirror only the first four bits from high ordered to low ordered or last four bits from high ordered to low ordered. Thank you very much!2013-01-20 03:54 PM
It's a shift right by 8 bits, So bit 8 goes to bit 0, and bit 15 to bit 7. In all A[8..15] to A[0..7]. It is a basic C operator.
So reading IDR as XXXXXXXX-------- And writing ODR as 00000000XXXXXXXX So A[12..15] reflected to A[0..3] GPIOA->ODR = (GPIOA->ODR & 0x00F0) | ((GPIOA->IDR >> 8) & 0x000F);2013-01-20 04:44 PM
Thanks clive... sorry for my ignorance but im reading books in c now but in parallel
So A[12..15] reflected to A[0..3] GPIOA->ODR = (GPIOA->ODR & 0x00F0) | ((GPIOA->IDR >> 8) & 0x000F); -> means? the value of GPIOA is pointed to the value of ODR, where ODR is equal to (GPIOA pointed to the values of 0000XXXX <12-15>) of (GPIOA pointed to the values of XXXX0000 <0-3>) correct?2013-01-20 06:18 PM
Sorry that should have read
''So A[8..11] reflected to A[0..3]'' Whereas A[12..15] reflected to A[0..3] would be GPIOA->ODR = (GPIOA->ODR & 0x00F0) | ((GPIOA->IDR >> 12) & 0x000F);2013-01-20 06:24 PM
2013-01-20 06:26 PM
just to finalize my questions.. hmm what does | do..
2013-01-20 06:35 PM
ahh clive is this what implements the pipeline in the ARM M series architecture?
2013-01-20 07:14 PM
ahh clive is this what implements the pipeline in the ARM M series architecture?
No, logical OR. The & is a logical AND You really need to get a decent text on the C language, like K&R