Skip to content

Instantly share code, notes, and snippets.

@battlecoder
Created July 10, 2024 06:29
Show Gist options
  • Save battlecoder/9155578ee34b826fdcedd45f8000ea4a to your computer and use it in GitHub Desktop.
Save battlecoder/9155578ee34b826fdcedd45f8000ea4a to your computer and use it in GitHub Desktop.
Quick LCG Test for MAX826550 Power Profiling
/* **** Includes **** */
#include "max32650.h"
#include "lp.h"
#include "mxc_errors.h"
#include "mxc_sys.h"
#include "led.h"
#include "pt.h"
/* **** Definitions **** */
// Uncomment to run with slower clock
//#define SLOW_SPEED
#ifdef SLOW_SPEED
#define BLINK_ITERS 10000
#else
#define BLINK_ITERS 100000000
#endif
int main(void) {
// Test sequence. Ignored during power profiling
LED_On(LED_RED);
LED_Off(LED_RED);
LED_On(LED_GREEN);
LED_Off(LED_GREEN);
#ifdef SLOW_SPEED
int error = MXC_SYS_Clock_Select(MXC_SYS_CLOCK_NANORING);
if (error != E_NO_ERROR) {
LED_On(LED_GREEN);
}
#endif
unsigned long lcg_seed = 0x50000L; // Could be any value
unsigned long iterations = 0;
while (1) {
lcg_seed = (lcg_seed * 1103515245L + 12345L) % 2147483648L;
iterations++;
if (iterations % BLINK_ITERS == 0) LED_Toggle(LED_RED);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment