- #define PHOTO_PIN 4
- int lightLevel = 0;
- static const TickType_t lightDelay = 2000 / portTICK_PERIOD_MS;
- static TimerHandle_t lightTimer = NULL;
- void setup() {
- Serial.begin(38400);
- delay(1000);
- Serial.println("Load timer");
- lightTimer = xTimerCreate(
- "lightTimer",
- lightDelay,
- pdTRUE,
- (void *)0,
- lightTimerCallback);
- Serial.println("Start timer");
- xTimerStart(lightTimer, portMAX_DELAY);
- vTaskDelete(NULL);
- }
- void lightTimerCallback(TimerHandle_t xTimer) {
- Serial.print("core: ");
- Serial.println(xPortGetCoreID());
- lightLevel = analogRead(PHOTO_PIN);
- Serial.print("lightLevel: ");
- Serial.println(lightLevel);
- }
- void loop() {
- }
Software timer assigned core
-
- Posts: 9
- Joined: Wed Mar 16, 2022 7:20 pm
Software timer assigned core
Hello. In the attached code, the timer routine always executes on Core 0. Is that a guarantee? Will it always run on Core 0, or is it just because Core 0 doesn't have anything else running at this time? Also, how would I pin this routine to Core 1?
Who is online
Users browsing this forum: No registered users and 83 guests