Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:56 01 Aug 2025 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 : port(21,2) not simultaneous on picomite?

     Page 1 of 2    
Author Message
crez

Senior Member

Joined: 24/10/2012
Location: Australia
Posts: 152
Posted: 11:05am 05 Jun 2022
Copy link to clipboard 
Print this post




setpin 21,dout
setpin 22,dout

do
 port(21,2) = 1
 port(21,2) = 2
loop

1k resistor from pin 21 to point A
2k resistor from pin 22 to point A

I expected to see pulse changing from 1/3 to 2/3 vcc.

Waveform at point A shows brief (around 1 microsecond) periods when both outputs are high and also both outputs low. Waveform also shows occasional longer periods (around 15 microseconds) when both outputs go low. It looks like the pins are updated sequentially, and occasionally an interrupt separates the two updates.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 11:35am 05 Jun 2022
Copy link to clipboard 
Print this post

  Quote  port(21,2) not simultaneous on picomite?

Nor on any other version of MMBasic
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2640
Posted: 12:13pm 05 Jun 2022
Copy link to clipboard 
Print this post

"Waveform also shows occasional longer periods (around 15 microseconds)"

Have also seen this when receiving a data stream. Rising edges sometimes recorded 5 to 15uS later than when they actually happened.

One possibility is the USB interface requiring attention occasionally.

In that instance, with a little arithmetic, just the falling edges could be used to get clean data.
.
Edited 2022-06-06 08:12 by phil99
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2950
Posted: 11:34pm 05 Jun 2022
Copy link to clipboard 
Print this post

Crez,

What happens if you put a small capacitor at point A to GND?

I would experiment with 10nf and Increase or decrease till you get the effect you wish (or it totally fails and you give up)

Regards,

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
crez

Senior Member

Joined: 24/10/2012
Location: Australia
Posts: 152
Posted: 09:33am 07 Jun 2022
Copy link to clipboard 
Print this post

I have done a bit of machine code programming in the past and could either change a port one bit at a time or do a parallel load, which changed 8 bits simultaneously. I thought the port() command would be like the latter. Mick, you are right, a capacitor would do the trick, and a few extra microseconds delay would not hurt at all. Without it the 3v spikes would cause false triggers on the device monitoring this output.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 11:37am 07 Jun 2022
Copy link to clipboard 
Print this post

I think, if you have a look at the RP2040 Datasheet, that the RP2040 has one single GPIO port which is 32 bits wide. I don't see how it can be accessed as actual physical ports at all (unless it's all the bits at once), unlike for example a PIC that may have ports A, B C etc.

All versions of MMBasic (AFAIK) use a system of "virtual" ports which is more flexible than the pysical ports but has the problem noted here.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 07:02am 08 Jun 2022
Copy link to clipboard 
Print this post

Hi Mick,

The PIC has 8 bit wide registers. The IO pins are grouped into groups of 8. and for each group of 8 there is an 8 bit DATA register, and an 8 bit DATA DIRECTION register (and in more modern PIC's there is an 8ndividual 8 bit pullup register, and 8 bit DATA-IN register etc..).

But in essence, and byte write to a single register can set 8 databits at the same time.

The RP2040 (and many ARM based chips I have dealt with in the recent past) have PIN registers. So each individual pin has it's own input register, and it's own output register. So unless you attach the pin to a alternate function (read: hardware inside the chip), software individually writes to each pin. And there will be time differencen between behaviour of individual pins.

Appart from that:

The PORT command allows you to map ranges of pins to a port. These ranges can skip pins (port 2,2,16,4 is completely valid), and can also spread over different (PIC style) ports. So it s inevitable that the port command shows small delays between pins that toggle (and pins that are read).

PIO

In the specific shown case (2 pins) the PIO can help solve the problem. A small PIO program can parallel write i.e. 5 pins, and can be controlled from a PIO WRITE.

HARDWARE

In many cases the pins do not drive H bridges of similar directly. Hardware (a latch function) can also solve the problem and make GPIO changes simultaneous.
PicomiteVGA PETSCII ROBOTS
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 07:51am 08 Jun 2022
Copy link to clipboard 
Print this post

I've played with PICs a few times in the past. :) One of my favourite things was the interrupt on change facility, to issue an interrupt if any of the bits in a port changes status. Very neat. The larger chips also support parallel IO using ports, also very neat. You do get the port clashes though, where the pins you have to use for something else prevent you from using a port. :(

The venerable (and still made, but more up to date now) Z80 had special command lines for port I/O, allowing 256 8-bit ports that took up no memory space. Very useful.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 08:01am 08 Jun 2022
Copy link to clipboard 
Print this post

For the PIC32MX170 + an interactive (dialect of) BASIC. This is where ByPic shines. Direct access to the "metal".







Craig
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 08:15am 08 Jun 2022
Copy link to clipboard 
Print this post

Pity it's no longer supported. :(
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 08:23am 08 Jun 2022
Copy link to clipboard 
Print this post

  Mixtel90 said  Pity it's no longer supported. :(


How come the concept of a finished, robust, working product doesn't work in our world?

I just write code and [shock-horror] it does what it's supposed to  

"Yeah, your new car looks awesome but what's with the square wheels?"

"Well that's why I bought it...because it's still under development"  




Craig
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 09:16am 08 Jun 2022
Copy link to clipboard 
Print this post

crez

I think I've found a way of doing simultaneous update. Are you using normal version or VGA. Let me know and I'll post a test version.

If anyone else wants to test let me know which version
 
Michal
Senior Member

Joined: 02/02/2022
Location: Poland
Posts: 125
Posted: 09:38am 08 Jun 2022
Copy link to clipboard 
Print this post

  matherp said  crez

I think I've found a way of doing simultaneous update. Are you using normal version or VGA. Let me know and I'll post a test version.

If anyone else wants to test let me know which version


I would like a PicoMite version

Michal
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 09:44am 08 Jun 2022
Copy link to clipboard 
Print this post

Try this and let me know


PicoMite.zip
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 09:47am 08 Jun 2022
Copy link to clipboard 
Print this post

  Quote  How come the concept of a finished, robust, working product doesn't work in our world?

Because it's not within the capacity of most people to know that something genuinely is finished and has no hidden errors. If code is no longer supported and a certain obscure combination of data or sequence of instructions after the device has been running for a certain time then you have no-one to fall back on to sort out the problem. That sort of code is fine where there is no risk as failures just mean pressing the reset button, but it shouldn't be used otherwise. If you have the source code and can debug it yourself then that's a different matter - you can fix it.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 11:17am 08 Jun 2022
Copy link to clipboard 
Print this post

  Quote  
If you have the source code and can debug it yourself then that's a different matter - you can fix it.


This excuse has been used since forever but in reality, if one had the skills to do such a thing, they wouldn't be using such a HLL in the first place.

The other reality is that there are endless ways to approach a coding problem...just take another approach.

There is a comprehensive collection of working-code samples for the ByPic and because it deals directly with the hardware, one only needs to use the MX170 datasheet to understand the registers and one can accomplish pretty-much anything.  





Craig
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 11:32am 08 Jun 2022
Copy link to clipboard 
Print this post

It's true that having the source code doesn't automatically keep you safe, but it does mean that *someone* can do some debugging. If you can't get the source then it's highly unlikely that anyone can ever fix it so the bug will lurk forever.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 11:58am 08 Jun 2022
Copy link to clipboard 
Print this post

Sorry to have a winge but when I post test software specifically to address the issue raised by the OP it would be helpful if the relevant posts weren't swamped by off-topic discussions
Edited 2022-06-08 21:59 by matherp
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 12:38pm 08 Jun 2022
Copy link to clipboard 
Print this post

  matherp said  Try this and let me know

PicoMite.zip


Just tried it. Have not been able to detect even 1ns difference when running the OP test program. This is marvelous !!! Can we have that please in all pico versions (also the VGA version).

Thanks a lot for making this possible. It opens a whole new area of possibilities.

Volhout
PicomiteVGA PETSCII ROBOTS
 
crez

Senior Member

Joined: 24/10/2012
Location: Australia
Posts: 152
Posted: 10:02am 09 Jun 2022
Copy link to clipboard 
Print this post

Thanks Peter, I've never been referred to as the OP before .The Picomite version suits me. I will get a chance to try it on the weekend.
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025