{"id":4292,"date":"2025-12-10T13:44:41","date_gmt":"2025-12-10T18:44:41","guid":{"rendered":"https:\/\/www.yorku.ca\/professor\/drsmith\/?p=4292"},"modified":"2025-12-10T13:44:41","modified_gmt":"2025-12-10T18:44:41","slug":"exploring-risc-v-options-the-rp2350-part-4-serial-monitor-tooling","status":"publish","type":"post","link":"https:\/\/www.yorku.ca\/professor\/drsmith\/2025\/12\/10\/exploring-risc-v-options-the-rp2350-part-4-serial-monitor-tooling\/","title":{"rendered":"Exploring RISC-V Options: the RP2350 (Part 4 -- Serial Monitor Tooling)"},"content":{"rendered":"\n<p>It's easy to get caught in weird assembler errors.  This is made more difficult if you don't have a background debugger and need to use a boot loader \/ serial monitor to debug your system.  Sometimes that's all you have.<\/p>\n\n\n\n<p>So here is a suggestion for a C++ and Assembler file pair to check to see if you're both entering and exiting the Assembler function using the Arduino IDE and its serial monitor.  If all is well you should see the monitor do this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"401\" height=\"159\" src=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2025\/12\/Screenshot-2025-12-10-at-1.27.57\u202fPM.png\" alt=\"\" class=\"wp-image-4293\" srcset=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2025\/12\/Screenshot-2025-12-10-at-1.27.57\u202fPM.png 401w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2025\/12\/Screenshot-2025-12-10-at-1.27.57\u202fPM-300x119.png 300w\" sizes=\"auto, (max-width: 401px) 100vw, 401px\" \/><figcaption class=\"wp-element-caption\">Serial monitor informing you that you have entered and then exited the assembler function.<\/figcaption><\/figure>\n\n\n\n<p>Here are the two files: riscv_standalone_asm_serialmonitor.ino and myAsmFunction.S:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ riscv_standalong_asm_serialmonitor.ino\n\/\/ Have the Arduino IDE provide messaages to the serial monitor as we enter and exit the assembler function\nextern \"C\" void myAsmFunction(void); \/\/ define the assembler function's name.\n\nvoid setup() {\n  Serial.begin(9600);\n  while (!Serial) { ; }\n  Serial.println(\"Entering the assembler...\");\n\n  \/\/ put your setup code here, to run once:\n  myAsmFunction();\n  \n  Serial.println(\"Exited the assembler...\");\n}\n\nvoid loop() {\n  \/\/ after the assembler runs, catch in infinite loop...\n  Serial.println(\".\");\n  delay(200);\n}\n\n<\/code><\/pre>\n\n\n\n<p>and then the assembler file: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># myAsmFunction.S\n#\n# By James Andrew Smith; Dec 10, 2025\n# \n# Just count down a few times and return to C++ code.\n# -----------------------------------------------\n.section .data\n# nothing in here.\n.section .text\n.global myAsmFunction\nmyAsmFunction:\n# Set up number of times to count down in register t4\n  li    t4, 5           # replace 5 with desired  count\n# -------------- loop a few times -------------------\nmy_loop:\n    # Decrement  count\n    addi t4, t4, -1\n    bnez t4, my_loop\n# ------------- end of loop ----------------------\n# ------- EXIT - Return to Arduino C++ ------------\n\tret<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"excerpt":{"rendered":"<p>It's easy to get caught in weird assembler errors. This is made more difficult if you don't have a background debugger and need to use a boot loader \/ serial monitor to debug your system. Sometimes that's all you have. So here is a suggestion for a C++ and Assembler file pair to check to [&hellip;]<\/p>\n","protected":false},"author":762,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","footnotes":""},"categories":[42,43,45,46,693],"tags":[912,907,911,908],"class_list":["post-4292","post","type-post","status-publish","format-standard","hentry","category-arduino","category-assembler","category-c-2","category-c-programming","category-risc-v","tag-bdm","tag-rp2350","tag-serial-monitor","tag-xiao-rp2350"],"taxonomy_info":{"category":[{"value":42,"label":"arduino"},{"value":43,"label":"assembler"},{"value":45,"label":"c"},{"value":46,"label":"c programming"},{"value":693,"label":"RISC-V"}],"post_tag":[{"value":912,"label":"BDM"},{"value":907,"label":"RP2350"},{"value":911,"label":"serial monitor"},{"value":908,"label":"Xiao RP2350"}]},"featured_image_src_large":false,"author_info":{"display_name":"drsmith","author_link":"https:\/\/www.yorku.ca\/professor\/drsmith\/author\/drsmith\/"},"comment_info":"","category_info":[{"term_id":42,"name":"arduino","slug":"arduino","term_group":0,"term_taxonomy_id":42,"taxonomy":"category","description":"","parent":0,"count":30,"filter":"raw","cat_ID":42,"category_count":30,"category_description":"","cat_name":"arduino","category_nicename":"arduino","category_parent":0},{"term_id":43,"name":"assembler","slug":"assembler","term_group":0,"term_taxonomy_id":43,"taxonomy":"category","description":"","parent":0,"count":30,"filter":"raw","cat_ID":43,"category_count":30,"category_description":"","cat_name":"assembler","category_nicename":"assembler","category_parent":0},{"term_id":45,"name":"c","slug":"c-2","term_group":0,"term_taxonomy_id":45,"taxonomy":"category","description":"","parent":0,"count":51,"filter":"raw","cat_ID":45,"category_count":51,"category_description":"","cat_name":"c","category_nicename":"c-2","category_parent":0},{"term_id":46,"name":"c programming","slug":"c-programming","term_group":0,"term_taxonomy_id":46,"taxonomy":"category","description":"","parent":0,"count":50,"filter":"raw","cat_ID":46,"category_count":50,"category_description":"","cat_name":"c programming","category_nicename":"c-programming","category_parent":0},{"term_id":693,"name":"RISC-V","slug":"risc-v","term_group":0,"term_taxonomy_id":693,"taxonomy":"category","description":"","parent":0,"count":19,"filter":"raw","cat_ID":693,"category_count":19,"category_description":"","cat_name":"RISC-V","category_nicename":"risc-v","category_parent":0}],"tag_info":[{"term_id":912,"name":"BDM","slug":"bdm","term_group":0,"term_taxonomy_id":912,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":907,"name":"RP2350","slug":"rp2350","term_group":0,"term_taxonomy_id":907,"taxonomy":"post_tag","description":"","parent":0,"count":5,"filter":"raw"},{"term_id":911,"name":"serial monitor","slug":"serial-monitor","term_group":0,"term_taxonomy_id":911,"taxonomy":"post_tag","description":"","parent":0,"count":2,"filter":"raw"},{"term_id":908,"name":"Xiao RP2350","slug":"xiao-rp2350","term_group":0,"term_taxonomy_id":908,"taxonomy":"post_tag","description":"","parent":0,"count":5,"filter":"raw"}],"_links":{"self":[{"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/posts\/4292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/users\/762"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/comments?post=4292"}],"version-history":[{"count":1,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/posts\/4292\/revisions"}],"predecessor-version":[{"id":4294,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/posts\/4292\/revisions\/4294"}],"wp:attachment":[{"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/media?parent=4292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/categories?post=4292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/tags?post=4292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}