![]() |
Forum Index : Microcontroller and PC projects : CMM2 add functionality
Author | Message | ||||
gwboyd Newbie ![]() Joined: 05/08/2020 Location: AustraliaPosts: 3 |
This question must surely have been answered somewhere in the forum but I cannot find it so I will ask it here. If one wants to add a function to the firmware on the CMM2 (it is clearly stated that this is easy to do) what are the actual steps involved?? The section that describes this on the website follows : Adding Functionality MMBasic has a simple mechanism for adding functionality that is both elegant and efficient. This allows the easy addition of new commands, functions and operators. For example, let us say that you want to implement a function that returns a special value generated by your hardware. In one file you would define the C function to perform the operation: void fun_myfun(void) { fret = (float)special_data_to_return; } And in another file you insert the definition of your function into the function table. This links the function name in BASIC ("MyFunction") with the C function (fun_myfun): { "MyFunction", T_FNA | T_NBR, 0, fun_myfun }, MMBasic will do the rest and in your BASIC program you can use the function like any other: PRINT MyFunction/100 This mechanism also applies to commands and even to arithmetic and string operators (ie, +, -, /, etc). |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
You don't add Cfunctions to the MMBasic function table. Your Cfunction is used in the same way that user SUBs and FUNCTIONs are used. You have to write the C code, compile it to produce a *.ELF file convert the ELF file to a MMBasic Cfunction using the supplied "armcfgenV143.bas" Include the Cfunction in your Basic program. Jim VK7JH MMedit |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
That's about how to add more functions to MMBasic itself. If that's what you want, you get the source, make the changes and rebuild the C then reflash the CPU. (Well, practice without making any source code changes first.) The details of a rebuild inevitably depend on the CPU (so are somewhat different for PIC32 & STM32) and of course the toolset & host OS used. John Edited 2020-08-06 16:29 by JohnS |
||||
gwboyd Newbie ![]() Joined: 05/08/2020 Location: AustraliaPosts: 3 |
I understand the C functions bit (although I have not attempted to use them yet) but my question was more about adding my own function / command in Custom.c then rebuilding the C to a final hex file suitable for uploading to the STM32. What are the steps required to build the hex file - is it simply compile all files with the gcc arm compiler, link the files (is it the same linker as used in the C functions example?) and then converting to a hex file - again using the method for C functions? I suppose a tutorial or a list of required steps from someone who has done the rebuild would point me in the right direction. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
This post might help https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=12189#147389 If you want to add more commands/functions, you will have to decide which existing ones you can remove. The available slots are full. Jim VK7JH MMedit |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
Hi gwboyd, I know that your question is simple but we don't have a tutorial for rebuilding the source and we certainly don't provide any support for anyone trying to do that. It is not for the faint-hearted and you need to be skilled in this process (you sound as if you are). If you want to give it a go you will need to download Atollic TrueSTUDIO for STM32 (free) and then import the directory into the Attolic workspace. To get it to compile you must then use the Project/Manage Build Configurations tab and set the active to release. The debug configuration isn’t complete. This is all that I can offer and hopefully it will get you started. Geoff Geoff Graham - http://geoffg.net |
||||
darthvader Regular Member ![]() Joined: 31/01/2020 Location: FrancePosts: 87 |
1 : Install STM32CubeIDE 2 : Get CMM2 source from Geoff page. 3 : Unzip the source into the STM32CubeIDE 'Workspace' folder. 4 : Open the project with STM32Cube IDE. 5 : Made your change in the source (or not) 5 : Build a Release. 6 : Reflash your CMM2. 7 : Your done ![]() Cheers. Theory is when we know everything but nothing work ... Practice is when everything work but no one know why ;) |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
Also, if you're going to make changes, think how you'll re-do them as newer versions of the code become available. John |
||||
Mattsaintdev Newbie ![]() Joined: 03/08/2020 Location: United KingdomPosts: 3 |
Hi - i havent used this IDE before - have the source and STM32CubeIDE installed - at step 4 - open the project - is there any specific file to select at the project to open ? IGNORE ME - didnt work under linux - moved to windows and it all compiled AOK Edited 2020-08-08 05:00 by Mattsaintdev |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
That's very disappointing to hear. John |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |