|
Forum Index : Microcontroller and PC projects : New addition to MMBasic
| Author | Message | ||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
Hello group. I'd like to see the CPUType function become part of MMBasic proper. I know there is a CPUType CFunction distributed with the Mk2 firmware but that is the problem - I can't run that CFunction on MMX or ARMMite (easily). If it were truly part of the firmware that would mean any code could become platform independent and a test at the beginning of the program followed by a Select, each section of which defines the variables for the named pins. I use CPUType() to configure software so I can load it on any platform, by checking the CPU and then setting CONSTs for pins (i.e. by name) accordingly. This makes my code easily portable between different 'mites. I have some code which can be deployed on both 28 & 44 pin mites which self configures - as an example: Select case CPUType() case 1,2 ? "28 pins" Const MyPin=2 case 3,4 ? "44 pins" Const MyPin=1 case 5 ? "64 pins" Const MyPin=53 case 6 ? "100 pins" Const MyPin=77 case else ? "Unknown CPU" End End select CFunction CPUType 00000000 3C03BF81 8C62F220 8C64F220 3C030660 7C84D800 24630053 10830028 3C03F99E 7C42D800 3463FFAD 00431021 2C420001 3C03BF81 8C69F220 3C040661 8C67F220 3485A053 8C66F220 7D29D800 01254826 7CE7D800 8C65F220 2484A053 3C030580 24080003 00E42026 3463A053 0109100A 7CC6D800 24070004 00E4100A 00C33026 7CA4D800 24631000 24050005 10830006 00A6100A 00402021 00002821 00801021 03E00008 00A01821 24040006 00002821 00801021 03E00008 00A01821 1000FFDC 24020002 End CFunction Now I want to move it to my H7 but it means I have to have lumps of code kept seperatley which I have to paste in - this then makes the body of the program incompatible and I have to remember to check/remove a lump of it each time when I start with a different CPU. It's a royal PitA. Would be really useful and if the above hex is anything to go by, a pretty small addition (assuming the mechanism is comparable on each platform). The entire MMBasic family could be catered for, Pi, DOS... h |
||||
| lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3467 |
Plus 1 and thanks for that code. I just yesterday encountered a condition where I wanted to discriminate between a 28-pin and a 44-pin. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
welcome. The CFunction does the heavy lift - is not my work (it is part of the MkII distribution) h |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
Look at MM.DEVICE$ first. This will distinguish all flavours of MMX, Armmite and Pi-Cromite. Then you only need to call the Cfunction to check pin count on MM2 and MM+. No changes to Basic needed. |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
Cheers for the idea, but that won't work for everything. With MMX, fairly certain they report as the same device and there are two variants. |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
No: gives the chip ID and there are 9 variants ] #define PIC32MZ2048EFG144_DEVID 0x07222053 #define PIC32MZ2048EFH144_DEVID 0x07227053 #define PIC32MZ2048EFM144_DEVID 0x0724f053 #define PIC32MZ2048EFG100_DEVID 0x0720E053 #define PIC32MZ2048EFH100_DEVID 0x07213053 #define PIC32MZ2048EFM100_DEVID 0x0723B053 #define PIC32MZ2048EFG064_DEVID 0x07204053 #define PIC32MZ2048EFH064_DEVID 0x07209053 #define PIC32MZ2048EFM064_DEVID 0x07231053 void fun_device(void){ char p[16]; IntToStr(p,DEVID,16); sret = GetTempStrMemory(); // this will last for the life of the command strcpy(sret, "Micromite eXtreme, Microchip ID 0x"); strcat(sret,p); CtoM(sret); targ = T_STR; } |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
Nine! blimey - I have two of the 144pinners here. Don't think I can keep up! Thanks for that |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |