Optimization of changing bit on port
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2014-05-10 3:35 PM
Posted on May 11, 2014 at 00:35
Can the following code be made more efficient other than not having a function. Using a STMF405 and all I am trying to do is set bit 14 on Port C.
#define GPIOC 0x40020800
#define GPIOC_BSRR_OFFSET 0x18 #define BIT14_ON 0x00004000 #define GPIOC_BSRR_ADDRESS GPIOC + GPIOC_BSRR_OFFSETunsigned int volatile * GPIOC_BSRR = (unsigned int *)GPIOC_BSRR_ADDRESS;
void rx_tx_on(void) { *GPIOC_BSRR = BIT14_ON; }
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2014-05-10 7:23 PM
Posted on May 11, 2014 at 04:23
It all depends on what the compiler does with it, adept use of registers in assembler would allow you the ultimate flexibility.
In C GPIOC->BSRR = GPIO_Pin_14; Would probably be as efficient, and you could tell the compiler to inline it.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
