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: serial I/O (from MMB4L)
Page 1 of 2 | |||||
Author | Message | ||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
Hi folks, Finally back trying to finish alpha 3 of MMB4L. I'm using a PicoMite to test MMB4L's serial I/O and have it working (as far as I can tell) where MMB4L talks to the PicoMite over the latter's serial console. I'm now moving over to talking to the PicoMite via its COM ports and *think* I have found a bug on the PicoMite. This is the transmit code running on MMB4L: ' MMB4L code to continuously transmit lines containing "Hello World". Option Base 0 Option Default None Option Explicit On Open "/dev/ttyUSB0:9600" As #1 Do Print #1, "Hello World" Loop This is the receive code running on the PicoMite: ' PicoMite code to receive data via serial I/O and echo to console. Option Base 0 Option Default None Option Explicit On SetPin GP1, GP0, COM1 'Open "COM1:9600" As #1 ' (1) Prints "Hello World" continuously - OK 'Open "COM1:9600,256,foo,1" As #1 ' (2) Prints "foo" or "Hfoo" and ends - OK Open "COM1:9600,256,foo,2" As #1 ' (3) Prints "Hello World" continuously - BUG? Dim ch$ Do ch$ = Input$(1, #1) Print ch$; Loop Close #1 Sub foo() Print "foo" End End Sub As you can see from the code comments I think there is a PicoMite BUG with case 3 where the interrupt trigger is 2 characters, am I correct or is there something I am missing ? Best wishes, Tom Edited 2022-01-05 07:34 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3641 |
I think not a bug. It never sees 2 buffered chars because you keep removing at least 1. John |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5867 |
If you put a delay in your DO LOOP, there will be sufficient time for the second character to accumulate. Any serial is slow. 9600 if bloody slow. Jim Edited 2022-01-05 08:54 by TassyJim VK7JH MMedit MMBasic Help |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
Thanks, I now understand both how it works and what the intended use case is. This description in the manual confused me: i.e. no explicit mention of it being the number of characters in the buffer, just the "number of characters received". Expect more queries, Tom Edited 2022-01-05 10:08 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3641 |
Would be better if re-worded. John |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
Can anyone tell me how I configure two stop-bits or even parity without an interrupt on the PicoMite, the following both report "Syntax error": Open "COM1:9600,1024,,256,S2" As #1 Open "COM1:9600,1024,,256,EVEN" As #1 Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8517 |
From the manual |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
D'Oh! that's what comes from not having a printed manual to obsessively read. The problem is printed manual's for the CMM2 and PicoMite are out-of-date before they arrive. Thank you Peter, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 3423 |
Hi Tom, You specified there should be an interrupt trigger after 256 characters. But when you do not specify the interrupt routine, you get a syntax error. SetPin GP13,GP16,COM1 Open "COM1:9600,128,do_it,16,even,s2" As #1 Close #1 Sub do_it End Sub The picomite user manual can be found at Geoff's website... All about picomite See appendix A of the manual Edited 2022-01-05 20:15 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
Hi Volhout, That's because I had mistakenly persuaded myself I needed to specify all the arguments and that an empty interrupt argument would mean no interrupt irrespective of the trigger - it will in MMB4L . I have it, and had read Appendix A, though it appears I haven't succeeded in remembering much of it . Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
PicoMite bug or (another) user failure ? > ? MM.Info(Device) PicoMite > ? MM.Info(Version) 5.0703 > List "bug.bas" Option Base 0 Option Default None Option Explicit On SetPin GP1, GP0, COM1 Open "COM1:9600" As #1 Close #1 Open "COM1:9600" As #1 Close #1 End > run "bug.bas" [9] Open "COM1:9600" As #1 Error : Pins not set for COM1 Obviously this is a much reduced version of some code which had a reasonable purpose behind closing and reopening a serial port. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8517 |
Yep. Close releases the pins from their function. Otherwise there would be no way to re-use the pin in a program. Same for SPI, I2C, PWM |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
Right you are. Thanks again, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 3423 |
Debate-able, I am in line with Tom. The Setpin command attaches the pins to the UART. Opening and closing the UART communication should not detach the pins from the UART. Only way to detach the pins from the UART should be a new Setpin command. Reason I respond to this "not really trivial" discussion is that I just discovered that our software partner did the same in a machine. And by freeing up the pins the serial communication channel went bazurk (crazy) by a stream of BREAK characters every time they opened and closed the UART communication.(*) As long as the pins remain attached to the UART they will remain in idle state. Not BREAK. RESET is a different situation... Regards, Volhout (*) system communicating baudrate x and datatransfer baudrate y was implemented opening and closing the UART communication. PicomiteVGA PETSCII ROBOTS |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8517 |
Feel free to write it. Only a couple of hundred lines of complex C to support UART/SPI/I2C/PWM/IR and whatever I've forgotten. Whether rightly or wrongly the PicoMite supports very flexible pin allocation and this will always have positives and negatives. Detaching the pins puts them back in tristate mode so all that is needed is a pullup resistor to avoid the issue you identify. Not everything has to be solved in software Edited 2022-01-06 01:06 by matherp |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 3423 |
Hi Peter, Understood ! And yes, a pullup/down would have been required anyway, as to satisfy the initial signal levels before the UART is opened. Volhout PicomiteVGA PETSCII ROBOTS |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
Can I short-circuit several days of research and code-diving on the PicoMite (or at least get a pointer as to where specifically to look) and ask: - What is supposed to happen if you send/receive an 8-bit character, e.g. Chr$(129) when the port is configured as 7BIT ? - If ODD or EVEN parity is set then what happens / where is the code for if the parity check fails ? Thanks in advance, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8517 |
AFAIK The Picomite SDK doesn't implement parity checking. Incorrect chars may give a framing error and be binned but who knows? |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3807 |
Do any of the 'mites implement parity checking ? Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8517 |
Not by me. but the H/W may throw a error interrupt which is then serviced and discarded |
||||
Page 1 of 2 |
Print this page |