Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : picomite custom function to control RTS and CTS possible?
Page 1 of 2 | |||||
Author | Message | ||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2350 |
hi all, for those of you following the HID2CDC thread, you'll have noticed that keyboard operation is getting close to perfect, and hopefully we may have mouse support coming along at some future point. you may have also noticed that there are a whole load of unused GPIO pins on the second pico that are not doing anything... these represent an opportunity! i'd like to be able to make use of these unused GPIO pins to extend the I/O capabilities of the picomite VGA. but to do this nicely requires the use of out-of-band signalling between the two picos. fortunately serial over USB provides for this, in the form of 'virtual' RTS and CTS signal lines. is anyone in the position to create two small custom function for the picomite that can: (1) turn the CTS status line on and off, (2) read the status of the RTS line? i have asked Peter and Geoff about this (https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=16596) but received an immediate no. using these custom functions it becomes possible to send data to and receive data back from the HID2CDC without it interfering with the normal use of PRINT statements or keyboard input. everything else can be handled by a few simple functions that are held in the LIBRARY as transparent extensions to mmbasic. cheers, rob :-) |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6787 |
Why does it require out of band signalling when you have a receive buffer and an interrupt when characters are received? You just send the info and the receiver handles it completely automatically in MMBasic. Edit: CTS/RTS can be simulated using ordinary interrupts. Just toggle them as needed. Edited 2024-01-24 19:59 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2350 |
because the single communications channel between the two picos carries: 1. output from PRINT statements (although we can suppress this from appearing on the VGA screen, see below), 2. keyboard input read using INKEY$ and INPUT$(..., #0), 3. commands sent to the HID2CDC instructing it to configure and control GPIO pins, as well as data directed to mass storage devices, 4. return information from the HID2CDC such as input pin status and block data from mass storage devices. note that we can turn on/off the connection between PRINT statements and the VGA screen using OPTION lcdconsole: Print "starting test" Option lcdpanel noconsole Print "invisible text" Option lcdpanel console Print "finishing test" the above demonstrates sending a 'private' message from mmbasic to HID2CDC that does not display on the VGA screen. but there is no foolproof means of ensuring valid VGA output is not mistaken for a private message when received by the HID2CDC. to send an unambiguous private message, we need to: 1. assert CTS, 2. wait for HID2CDC to respond by asserting RTS. 3. we now know that the communications channel is available for private communications. 4. when finished, reset CTS, 5. wait for RTS to reset by the HID2CDC, then carry on with out basic program. using signalling via RTS/CTS provides the simplest, most reliable method of multiplexing the single communications channel between two very different functions. we then have a 12Mbps 2-way channel that can be used for a whole variety of tasks - the likes of off-boarding SD card, RTC, sound output, and possibly even video generation could be moved out of mmbasic. the end result would be a faster and more deterministic picomite. cheers, rob :-) |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2350 |
you do realize that RTS and CTS are already virtualized across a USB link? no extra physical pins or wires needed. cheers, rob :-) Edited 2024-01-24 20:45 by robert.rozee |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6787 |
I doubt very much if you would get anything like that to work in MMBasic anyway. The PRINT command is probably so low level that any changes to it would be horrific. Of course, just don't have a single communications channel. Use both COM ports or one COM and one I2C. They are completely private and use the same number of pins as implementing CTS/RTS. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2350 |
Mixtel90, i am talking about CDC communications over a USB link. this is two pico boards talking to each over USB. no other connections. there are no physical COM or I2C ports involved, nor any UARTs. communications across this link occurs at a fixed 12Mbps. RTS/CTS are virtualized signal lines, as such there is no connecting them to physical pins. i'm not sure how i can put this in simpler terms. to rephrase my initial question: is anyone in the position to create two small custom function for the picomite that can, for the virtual comm port provided by TinyUSB: (1) turn the virtual CTS status line on and off, (2) read the status of the virtual RTS line? these are the RTS/CTS signal associated with the USB port, not any physical comm port. cheers, rob :-) |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9115 |
the TinyUSB cdc_device header does not expose a function for manipulating CTS |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2350 |
darn - you are right Peter for the moment it looks like i'll have to make do with just using GP22 for signalling. the picomite will raise GP22 to indicate it wishes to send a command, and the HID2CDC will send a unique message back saying it is ready to receive one or more commands. since all(?) VT keyboard escape sequences contain no characters above 0x7F, i'll use 0xFF to signal back to the picomite that the HID2CDC is ready to receive commands. part of the rationale behind using RTS/CTS for signalling was to minimize use of GPIO pins on the picomite. in a picomite VGA Duo setup one of my goals is to free up as many of the picomite pins as possible (hence wanting to move RTC, etc to the HID2CDC). cheers, rob :-) Edited 2024-01-25 21:11 by robert.rozee |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6787 |
Could anything be done with something like XON/XOFF? Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2350 |
unfortunately not. when running normally, the picomite VGA sends all output (from PRINT statements) to both the VGA screen and up the USB connection. there is nothing to stop a user program from trying to print control characters such as XON, XOFF, or ESC. so we need a way to say to the HID2CDC "ignore all this junk being sent to you". likewise, when we want to send a command to the HID2CDC (such as "set your GP10 pin to output 1") we need a way to first signal to the HID2CDC that what it is about to receive is a valid command that it should perform. in an ideal world there would be a way to set up mmbasic to only send PRINT #99 ... output over the USB connection to the HID2CDC and for all regular PRINT ... output to only go to the VGA screen and not also to the HID2CDC. cheers, rob :-) |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6787 |
Of course, the USB connection is primarily the console connection, just as it is on all MMBasic platforms (that have one). Output to the VGA screen is graphical and should be done with the TEXT command. TEXT isn't sent to the console and PRINT is only sent to the VGA in command mode. What you are trying to do breaks the system nicely. :) You realize that it's possible to re-purpose TP5 (the Heartbeat LED output) as an extra GP pin, don't you? It produces about 2V when set high as it's directly across the green LED. Best used to turn a NPN transistor on and off, giving an inverted output. Useful if you are stuck for an extra pin. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
atmega8 Guru Joined: 19/11/2013 Location: GermanyPosts: 722 |
|
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2350 |
i am a tad confused here. i have sitting on my desk a picomite VGA attached to a VGA screen and a USB hub. attached to the hub is also a USB keyboard. a HID2CDC is attached to the host connector on the hub and routes keypresses to the picomite VGA via the USB CDC interface. with this, what i type at the keyboard appears on the VGA screen. a program that i type in using the USB keyboard and mmbasic editor and uses PRINT statements displays output on the VGA screen. i haven't got as far as using any graphics commands, but i expect them to freely mix with PRINT statements, with the proviso that if a print statement causes the screen to scroll then any graphics on screen at that time will also scroll. i presume there is some way to adjust the position on the screen where a PRINT statement places text output? something like gotoxy(x, y) or print @x,y? (just went away and checked: text 200, 200, "" print "hello world "; input a$ the above seems to work more-or-less correctly, the text appears in the middle of the screen and the cursor for the input is just to the right of the message) Mixtel90, what you seem to be describing is an archaic concept from the early days of computers, where text I/O was via a terminal, and graphics output would appear on a separate screen, often generated with analog voltages applied to X and Y plates within the CRT: it this what everyone on here expects of a picomite VGA?! is this how you all use it??? please, no offense intended, i just had never imagined the picomite VGA being used like this, always thinking of it more as a re-imagining of a 1980's home computer. i'd never seriously considered anyone would use it tethered to a PC running a terminal emulator. yes, i was aware of that, and had considered it. GP24 is also an input that could be repurposed. cheers, rob :-) Edited 2024-01-25 23:41 by robert.rozee |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9115 |
print @(x,y)"Whatever" The PicoMiteVGA can be used in either mode and fully supports the (still widely available) PS2 keyboard in a range of languages. The advantage of using it in tethered mode comes when developing large programs where things like MMEDIT, github,etc are available. Then it can be used stand-alone for running the programs Edited 2024-01-26 00:23 by matherp |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6787 |
From the PicoMite VGA manual: TEXT x, y, string$ [,alignment$] [, font] [, scale] [,c] [, bc] Displays a string on the VGA screen starting at 'x' and 'y' PRINT expression [[,; ]expression] … etc Outputs text to the console followed by a carriage return/newline pair. PRINT @(x [, y]) expression Or PRINT @(x, [y], m) expression Same as the standard PRINT command except that the cursor is positioned at the coordinates x, y expressed in pixels. If y is omitted the cursor will be positioned at “x” on the current line. You have to remember that the PicoMite VGA was derived from the ordinary PicoMite, which can only handle LCD displays. All graphics handling is sent to the graphics driver and all text handling is sent to the console. To send text to a graphics driver it has to be sent as graphics, hence the TEXT command. This allows it to be displayed in all sorts of manners, including color, scaling and rotated. Initially the PicoMite, like the Micromite, was an embedded controller. A program *user* was not intended to have console access at all (and can be locked out via a password), all operations would be carried out via the graphical display (or by some sort of hard-wired buttons and lamp/ text LCD display). This was because of security - if you have access to the console you can do anything. It has since grown closer to the Maximite and CMM2 in concept, more of a general purpose home computer. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2914 |
Hi All, Of course you could always solder to the point shown by the yellow arrow below and get a full 0-3.3V swing on GP25. If you removed the Resistor labelled R3 you could also use it as an input, assuming MMBasic allows GP25 to be an input. By Removing R3 it will expose a small pad to solder onto and allow `clean' access to GP25. Regards, Mick (The big one) EDIT*** Of course by removing R3 the LED will never illuminate. Mik . Edited 2024-01-26 15:26 by bigmik Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6787 |
Huh... I have a job even *seeing* R3, never mind waving a soldering iron anywhere near it! Mick (The optically challenged one) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
The output of TP5 is plenty enough to use as an input to another pico. I used it extensively when debugging Webmite reliability problems. Jim VK7JH MMedit MMBasic Help |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9115 |
For info, I'm 75% complete porting the CMM2 USB keyboard code to the PicoMiteVGA. This will be separate firmware with just minor changes from the standard PicoMiteVGA. A serial console will be enabled on GP8 and GP9 (replacing the PS2 keyboard) - this needs an external TTL-USB adapter (CP2102 or equivalent). 5V power needs to be supplied to VBUS and the keyboard is plugged into the Pico USB port via a micro-usb to USB-A female adapter. The update firmware command will disappear (use the button) The CMM2 keydown function will be available able to report up to 6 keys depressed and the status of all the modifier keys. Current status is that all CMM2 keyboard language variants are working including proper support for NUM-LOCK, Caps-lock etc. R-ALT is implemented for those languages that need it. Still to do is just key repeat and adding the keydown function Total programming time so far 3 hours |
||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2914 |
Hi Mick, Jim, All, You are speaking to the converted here, I have about 6 pairs of glasses lying around, each has different uses. My favourite is an Optician quality that is somewhere between the cheap +3 and +4 that I use for soldering. It took a lot of convincing ‘Specsavers’ to do them as they were adamant that “that is NOT what you want/need old fella” But seriously removing R3 is not that difficult and I would use single strand ‘wirewrap’ to solder to the pad and glue it to the pcb for strain relief. All that said, I have not done so. It was posted that it IS possible not that it is mandatory to do so. Mick (The big one) . Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
Page 1 of 2 |
Print this page |