{"id":21710237,"url":"https://github.com/rhthomas/kw41z-dev","last_synced_at":"2025-03-20T17:50:29.209Z","repository":{"id":81147453,"uuid":"108024459","full_name":"rhthomas/KW41Z-Dev","owner":"rhthomas","description":"COMP3215 Lab 1 – Implementing FreeRTOS using multiple development environments.","archived":false,"fork":false,"pushed_at":"2017-11-13T00:34:04.000Z","size":2523,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-25T16:32:00.221Z","etag":null,"topics":["arm-cortex-m0","freertos","gnu-toolchain","keil","nxp","rtos"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rhthomas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-23T18:43:58.000Z","updated_at":"2017-11-13T12:54:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"9bfaf8e1-6a07-4007-9032-10f53aff5e94","html_url":"https://github.com/rhthomas/KW41Z-Dev","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhthomas%2FKW41Z-Dev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhthomas%2FKW41Z-Dev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhthomas%2FKW41Z-Dev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhthomas%2FKW41Z-Dev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhthomas","download_url":"https://codeload.github.com/rhthomas/KW41Z-Dev/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244666423,"owners_count":20490286,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arm-cortex-m0","freertos","gnu-toolchain","keil","nxp","rtos"],"created_at":"2024-11-25T23:14:18.511Z","updated_at":"2025-03-20T17:50:29.202Z","avatar_url":"https://github.com/rhthomas.png","language":"C","readme":"# KW41Z-Dev\n\nThe idea of this lab exercise is to get experience and realise the pros and cons of different development environments. To demonstrate this, a simple RTOS program will be written, flashed and debugged for the FRDM-KW41Z on three different development environments:\n\n1. ARM Keil\n2. NXP MCUXpresso\n3. GNU FOSS Toolchain and Makefiles\n\nThe directory structure for this repository is as follows:\n\n```\nKW41Z-Dev/\n├── GNU/\n│   ├── README.md\n│   ├── RTOS_Blink/\n│   └── img/\n├── Keil/\n│   ├── README.md\n│   ├── RTOS\\ Blink/\n│   └── img/\n├── MCUXpresso/\n│   ├── README.md\n│   ├── RTOS_Blink/\n│   └── img/\n└── README.md\n```\n\n---\n\n## Simple RTOS Program\n\nThe RTOS program that will be written for the processor will simply toggle two different LEDs with different periods. A red on at 500ms, and a green one at 330ms.\n\nBelow is segments of the FreeRTOS functionality **ONLY**, i.e. no development platform specific functions or includes.\n\n### Main Function\n\nThe job of the main function is to create the two LED tasks and begin the OS scheduler.\n\n```c\nint main(void)\n{\n    // Create red LED task.\n    xTaskCreate(\n        LEDTask1, // Task function.\n        \"LEDTask1\", // Task name (for simulations).\n        configMINIMAL_STACK_SIZE, // Size of task stack.\n        (void *)NULL, // Parameter passed to task at startup.\n        (unsigned portBASE_TYPE)tskIDLE_PRIORITY+1, // Priority.\n        (xTaskHandle *)NULL // Pointer to reference of the task.\n    );\n\n    // Create green LED task.\n    xTaskCreate(\n        LEDTask2, // Task function.\n        \"LEDTask2\", // Task name (for simulations).\n        configMINIMAL_STACK_SIZE, // Size of task stack.\n        (void *)NULL, // Parameter passed to task at startup.\n        (unsigned portBASE_TYPE)tskIDLE_PRIORITY+1, // Priority.\n        (xTaskHandle *)NULL // Pointer to reference of the task.\n    );\n\n    // Start OS scheduler.\n    vTaskStartScheduler(); // No return!\n\n    return 0;\n}\n```\n\n### LED Tasks\n\nThe LED tasks are very basic. They consist of a while loop that forever turns on an LED, waits a period of time, then turns off the LED before again waiting. This is not at all efficient code however it is meant to only be a simple example.\n\n```c\nvoid LEDTaskN(void *pvPs)\n{\n    while (42) {\n        // Turn LED on.\n        vTaskDelay( tDelay_ms(500) );\n        // Turn LED off.\n        vTaskDelay( tDelay_ms(500) );\n    }\n}\n```\n\n### Converting RTOS *Ticks* to Seconds\n\nFor the `vTaskDelay` function, we cannot simply pass a millisecond wait time, we need to convert this to RTOS processor *ticks* which is done using a small converter function.\n\n```c\nportTickType tDelay_ms(const float ms)\n{\n    return (portTickType)(ms / portTICK_PERIOD_MS);\n}\n```\n\n---\n\n## Comparison Between Development Platforms\n\n### ARM Keil\n\n#### Pros\n+ Easy to use debugging interface.\n+ Able to batch build for multiple targets.\n+ Well designed and easy to use package manager.\n\n#### Cons\n- 32kB code limit.\n- Very expensive full version of the software.\n- Pulls in files from a variety of locations. Not sure what you're including.\n\n### MCUXpresso\n\n#### Pros\n+ Cross-platform IDE.\n+ Free.\n+ IDEs allow more time writing code rather than wasting time figuring out the toolchains.\n+ Easy debugging interface.\n+ Familiarity to those who have used Eclipse tools in the past.\n\n#### Cons\n- Based on Eclipse so is a fairly heavy editor for embedded platforms.\n    - Most of Eclipse isn't even used!\n\n### GNU Toolchains\n\n#### Pros\n+ Free.\n+ You know exactly what files are being compiled into your project.\n    + More control over code size.\n    + More control over security.\n        + Not pulling in random libraries you didn't write.\n+ Lightweight IDEs.\n    + Just need a text editor and a terminal.\n    + Use whatever text editor you like.\n        + Atom\n        + Vi/Vim\n        + Nano\n        + Notepad++\n\n#### Cons\n- Makefiles can be very complicated/convoluted.\n    - Spend more time debugging makefiles rather than actual code.\n- More complicated methods of making linker scripts.\n- More time spent setting up the toolchains rather than actually writing functional code for the target.\n- GDB in the command line has a steep learning curve.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhthomas%2Fkw41z-dev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhthomas%2Fkw41z-dev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhthomas%2Fkw41z-dev/lists"}