Last active
December 1, 2022 09:03
-
-
Save csrohit/ae7176560d56e5f80a40b22e286d223e to your computer and use it in GitHub Desktop.
Gist for supporting article on optimising code size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ms_delay(int ms) | |
{ | |
while (ms-- > 0) | |
{ | |
volatile int x = 1000; | |
while (x-- > 0) | |
__asm("nop"); | |
} | |
} | |
void unused_delay(int ms) | |
{ | |
while (ms-- > 0) | |
{ | |
volatile int x = 10; | |
while (x-- > 0) | |
__asm("nop"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(void) | |
{ | |
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN; | |
GPIOC->CRH = 0x02 << ((13 - 8) << 2); | |
while(1){ | |
GPIOC->ODR ^= 1 << 13; | |
ms_delay(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment