Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 07:26 22 Jan 2022 Privacy Policy
Jump to

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 Kingdom
Posts: 2077
Posted: 09:21pm 04 Jan 2022
Copy link to clipboard 
Print this post

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
CMM2 Welcome Tape, Creaky old text adventures
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 2613
Posted: 10:31pm 04 Jan 2022
Copy link to clipboard 
Print this post

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: Australia
Posts: 4537
Posted: 10:53pm 04 Jan 2022
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 2077
Posted: 11:28pm 04 Jan 2022
Copy link to clipboard 
Print this post

Thanks, I now understand both how it works and what the intended use case is.

This description in the manual confused me:

  picomite-manual said  'int-trigger' is the number of characters received which will trigger an interrupt.


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
CMM2 Welcome Tape, Creaky old text adventures
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 2613
Posted: 08:16am 05 Jan 2022
Copy link to clipboard 
Print this post

Would be better if re-worded.

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 2077
Posted: 09:47am 05 Jan 2022
Copy link to clipboard 
Print this post

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
CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5688
Posted: 09:59am 05 Jan 2022
Copy link to clipboard 
Print this post

From the manual

  Quote  Opening a serial port specifying the baud rate (9600 bits per second) and receive buffer size (1KB):
OPEN "COM2:9600, 1024" AS #8
The same as above but with two stop bits enabled:
OPEN "COM2:9600, 1024, S2" AS #8
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 2077
Posted: 10:06am 05 Jan 2022
Copy link to clipboard 
Print this post

  matherp said  From the manual ...


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
CMM2 Welcome Tape, Creaky old text adventures
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 1044
Posted: 10:14am 05 Jan 2022
Copy link to clipboard 
Print this post

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
If nothing goes right ... turn left
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 2077
Posted: 10:30am 05 Jan 2022
Copy link to clipboard 
Print this post

Hi Volhout,

  Volhout said  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 ...

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 .

  Quote  The picomite user manual can be found at Geoff's website...

I have it, and had read Appendix A, though it appears I haven't succeeded in remembering much of it .

Best wishes,

Tom
CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 2077
Posted: 02:07pm 05 Jan 2022
Copy link to clipboard 
Print this post

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
CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5688
Posted: 02:13pm 05 Jan 2022
Copy link to clipboard 
Print this post

  Quote  or (another) user failure ?


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 Kingdom
Posts: 2077
Posted: 02:24pm 05 Jan 2022
Copy link to clipboard 
Print this post

  matherp said  
  Quote  or (another) user failure ?


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


Right you are.

Thanks again,

Tom
CMM2 Welcome Tape, Creaky old text adventures
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 1044
Posted: 02:55pm 05 Jan 2022
Copy link to clipboard 
Print this post

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.
If nothing goes right ... turn left
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5688
Posted: 03:06pm 05 Jan 2022
Copy link to clipboard 
Print this post

  Quote  Only way to detach the pins from the UART should be a new Setpin command.


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: Netherlands
Posts: 1044
Posted: 03:18pm 05 Jan 2022
Copy link to clipboard 
Print this post

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
If nothing goes right ... turn left
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 2077
Posted: 03:59pm 05 Jan 2022
Copy link to clipboard 
Print this post

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
CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5688
Posted: 04:21pm 05 Jan 2022
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 2077
Posted: 05:17pm 05 Jan 2022
Copy link to clipboard 
Print this post

Do any of the 'mites implement parity checking ?
CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5688
Posted: 05:31pm 05 Jan 2022
Copy link to clipboard 
Print this post

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
© JAQ Software 2022