|
Forum Index : Microcontroller and PC projects : PICOMITE: GP issue when assigning pins using CONST...
| Author | Message | ||||
Grogster![]() Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9760 |
Hello all. ![]() Trying to set GP0 as an input, but MMBASIC throws an error: SetPin 0,DIN Error : Pin 0/NULL is reserved on startup. OK, fair enough. Use this instead: SetPin GP0,DIN That works fine. I normally use CONST to define the pin numbers with useful names for inside the code, such as CONST DOOR=05, WINDOW=06 - that kind of thing, then you setup the pins using the constants: SetPin DOOR,DIN and SetPin WINDOW,DIN kind of arrangement. It would seem this is NOT permitted on the PicoMite if you use the GP references. Is that correct or am I doing something wrong? If I try to do the above but replacing the numbers with GP references such as CONST DOOR=GP5, when run, the interpreter does NOT like that. Error : GP5 is not declared Am I correct that if I use the GP references, I have to just use them throughout the code and not have easy to remember versions? I think that might be the case.... Another example is if I try to use pin-numbers and CONST, the interpreter does not like that much either for certain pins. Take GP8. If I try to CONST DOOR=8, and then SetPin DOOR, DIN then that generates an error: Pin 8/GND is invalid. I'm using a WS Zero module, so do I have to simply remap the pins from it, to match the standard Pico module, then I could perhaps use the pin references. IE: Define GP0-GP29 as CONST, along the lines of CONST GP0=0,GP1=1,GP2=4... GP6=9,GP7=10,GP8=11.... THEN use SetPin GP8,DIN, which will in effect be SetPin 11,DIN if you see what I am getting at. Does that make any kind of sense, or is it all clear as mud? EDIT: I've just tried that out, and it works, so I have my answer. ![]() I'll leave the thread up for anyone to comment on though. Edited 2023-02-13 10:21 by Grogster Smoke makes things work. When the smoke gets out, it stops! |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2833 |
> const mypin=mm.info(pinno gp15) : ? mypin 20 > or > const gp14=mm.info(pinno gp14) : ? gp14 19 > setpin gp14,din > "MM.INFO$(PINNO GPnn) Returns the physical pin number for a given GP number. GPnn can be an unquoted string (GP01), a string literal(“GP01”) or a string variable. Ie, A$=”GP01”: MM.INFO(PINNO A$)" Edited 2023-02-13 11:05 by phil99 |
||||
Grogster![]() Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9760 |
Bloody perfect! Thanks - that's even better then my hack-it-up attempt. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
| JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4147 |
A mistaken edit / change of mind such as: const gp14=mm.info(pinno gp13) setpin gp14,din Could be confusing... John |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8304 |
It's called "security by obscurity", John. No-one knows what the hell is going on. Rather like where I used to work, actually. :) I hadn't thought of using const myname = mm.info(pinno GPn) like that. Good call, Phil. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2681 |
So much for basic being universal. Anyone used dir gp7 in or dir gp7 out on other basic? |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8304 |
No - and DIR GP7 IN doesn't work in MMBasic either. :) BASIC has never really been "standard". There have been "standard" versions - each for their own platforms - for years, which were tied to the hardware. That's what the PicoMite is - it has hardware that needs special BASIC commands to make it accessible. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4147 |
Generally it's not "universal" (unless you code very generic uninspiring stuff), though there is at least one ANSI standard - but it's not aimed at uC systems. I haven't but there are many non-standard variants of BASIC... Where did you meet those? John |
||||
| stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2681 |
Picaxe,gcbasic,mmbasic all Very different, even setting dir pin/port in or out. It's no fun converting existing code to mmbasic. Example is V53LOX which I tried in picaxe..thanks mmotte and hippy, then gcb and thanks anobium and I saw code in the shed mmbasic forum.. which was "read the data sheets" in a nasty way. As I'm using vga picomite I realise that a zx spectrum,c64,bbc micro/atom,dragon 32,cpc 464 all had different basics but adding picaxe,gcb and mmbasic is more problems. Treat is as new and forget the past? what could '80's computers do that mmbasic can't do better? edit Ranting a bit but converting just i2c is not trivial. Shame all that info I can't use and not talking about c. Edited 2023-02-14 06:37 by stanleyella |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8304 |
BASIC on the different platforms is different because the hardware is different. You *can* have a BASIC that looks (more or less) the same on all of them, but it will be very much simplified - a lowest common denominator for the minimal hardware. Look at Tiny BASIC as a typical example. It certainly won't support ADC, PWM, 1-wire and flash memory. Neither will it handle configurable IO pins. If you want to port programs between totally different hardware systems then you will definitely have to mess with the versions of BASIC that each supports. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2833 |
The closest you could get to a universal language would be to have an operating system layer to create a virtual machine that makes all the different hardware platforms look almost the same to the language. That needs much more power such as a PC, R-Pi etc. |
||||
Grogster![]() Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9760 |
Using phil99's prod and mm.info is working PERFECTLY, and I don't even have to think about remapping pins, cos that idea does it all for me. MM.INFO contains a rather large subset of useful bits of information you can return by using it, but that means I had completely forgotten about the one Phil reminded me about. ![]() Agreed. But as I always refer to pins by setting constants and giving them names, SO LONG as you don't mix-and-match named pins with the GP pin references, there SHOULD be minimal risk of getting confused. In other words, pick one or the other but not both. Use GP references or pin labels but not both. I like to use labels for all my pins, cos it is MUCH easier to remember what the line of code is doing on a given pin, if you have a pin called PIEZO for example - it has to be the piezo buzzer driver etc. Smoke makes things work. When the smoke gets out, it stops! |
||||
| stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2681 |
Microcontrollers and PC projects Programming, interfacing and using PicAxe, Duino, Maximites, PC's, etc. Not much picaxe but picaxe sorted lots of hobbyist hardware. No gcbasic but that also sorted same hobbyist hardware. MMbasic has sorted some of the same hobbyist hardware but not what the other basics have sorted so nice if could convert other basic to mmbasic but some would say read the data sheet and write your own code. I would if I could. If it was arduino then just include the device include and use it. Same with gcbasic but you can steal the code for your own use. mmbasic and how to get an unsupported device to work if you don't know how to implement the data sheet but can find working examples in another system is not fun. bbc,amstrad,sinclair,commode,dragon32,trs80 all different. converting to mmbasic not easy but they never used spi,i2c so what gets converted to mmbasic? |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8304 |
At one point those platforms didn't support the hardware bits either. Someone had to write the libraries. :) If you ever manage to convert Commodore BASIC programs into anything else you're doing well. That was probably the vilest BASIC (vilest keyboard on an old PET) I've ever had the misfortune to use. If you didn't know the POKEs to make anything work you were left in the dark ages. A C64 was the only computer I was finally glad to get rid of. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4147 |
One way would be to write a program to do (many of) the changes, i.e. automate it. Also, maybe adopt a set of your own ways of expressing hardware-dependent I/O (such as library calls and then you only have to tweak the library for each new hardware). The HAL etc of some OSes is somewhat similar. You have to face up to how very different hardware tends to be (for economic reasons each supplier wants to lock you in). Tom's "transpiler" is kind of in that direction I suppose. Have you met BASICs which require RIGHT, LEFT, MID but others that require RIGHT$, LEFT$, MID$ (I have)? Also, ones which disagree on the meaning of the arguments needed e.g. by RIGHT$? (Yes, they exist.) John Edited 2023-02-14 20:34 by JohnS |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8304 |
And the better ones... a$(1 TO 4) = b$(5 TO 6) + c$(7 TO) I love Sinclair's string slicing. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2681 |
My observation was arduino seemed to have libs for popular hobbyist hardware long before picaxe or gcb or now mmbasic. It was frustrating as I don't understand C.. or whatever arduino sketches are. Mick ... it was known as the "commode 64" but then zx was called "unclear spectrum" :) Not everyone can use data sheets, the ili9341 data sheet is a good example, I've seen the same init list in arduino and gcb. |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |