Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 00:14 04 Dec 2021 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 V5.07.00b24: I2C slave functionality

     Page 1 of 3    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5460
Posted: 10:02am 06 Oct 2021
Copy link to clipboard 
Print this post

PicoMiteV5.07.00b24.zip


Fixes a bug in opening a com port with a receive interrupt count
Fixes a bug with MM.INFO(CPUSPEED)

Implements full I2C slave functionality.
Basically the same as the MM2 except the slave open command is simplified

I2C[2] SLAVE OPEN i2c_slave_address, transmitinterrupt, receiveinterrupt


I2C[2] SLAVE WRITE sendlen, senddata [,sendata ....]

Send the data to the I2C master. This command should be used in the send
interrupt (ie in the 'transmitinterrupt' subroutine when the master has requested data).
Alternatively a flag can be set in the interrupt subroutine and the command
invoked from the main program loop when the flag is set.
'sendlen is the number of bytes to send.
'senddata' is the data to be sent. This can be specified in various ways, see the I2C
WRITE commands for details.


I2C[2] SLAVE READ rcvlen, rcvbuf, rcvd

Receive data from the I2C master device. This command should be used in the
receive interrupt (ie in the 'receiveinterrupt' subroutine when the master has sent some
data). Alternatively a flag can be set in the receive interrupt subroutine and the
command invoked from the main program loop when the flag is set.
'rcvlen' is the maximum number of bytes to receive.
'rcvbuf' is the variable to receive the data. This can be specified in various ways,
see the I2C READ commands for details.
'rcvd' is a variable that, at the completion of the command, will contain the actual
number of bytes received (which might differ from 'rcvlen').


I2C[2] SLAVE CLOSE

Disables the slave I2C module and returns the external I/O pins to a "not
configured" state. They can then be configured using SETPIN.

Exactly like the MM2 you MUST put the I2C[2] SLAVE READ and SLAVE WRITE commands in the interrupt routine or trigger them to respond very quickly afterwards in the main program.

e.g. Connect pin GP2 (pin 4) on the master to GP2 on the slave and GP3 (pin 5) on the master to GP3 on the slave

MASTER Pico
SetPin gp2,gp3,i2c2
I2C2 open 100,1000
i=10
Do
i=i+1
a$=Str$(i)
I2C2 write 50,0,Len(a$),a$
Pause 200
I2C2 read 50,0,8,a$
Print a$
Pause 200

SLAVE Pico
SetPin gp2,gp3,i2c2
I2C2 slave open 50,tint,rint
Do :Loop
'
Sub rint
Local count
'Print "RX"
I2C2 slave read 10,a$,count
Print Left$(a$,count)
End Sub
'
Sub tint
a$=Time$
I2C2 slave write 8,a$
'Print "TX"
End Sub

Loop
Edited 2021-10-06 21:08 by matherp
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 1196
Posted: 03:14pm 06 Oct 2021
Copy link to clipboard 
Print this post

This looks interesting. Cheap & intelligent I/O expansion.
-- Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5460
Posted: 10:52am 07 Oct 2021
Copy link to clipboard 
Print this post

PicoMiteV5.07.00b25.zip


This release changes the OPTION MEMORY command to make things simpler (I hope). Depending on any MEMORY options you have set it may reset all the options.

Changes:

OPTION MEMORY now has only one parameter. This is the number of KBytes of program memory to set. This can be between 1 and half of the available memory (160Kbytes if no GUI controls are enabled)

OPTION GUI CONTROLS sets the number of GUI controls you want available (defaults to 0). It will automatically change the amount of memory available for variables and the program in a sensible way. i.e. share the memory between them or take it all from the variables if less than 16K has been specified for the program. If the number of GUI controls is reduced the firmware will share the returned memory between the program and variable space

GUI memory is allocated in blocks of 2K which roughly equates to 39 GUI controls

OPTION LIST now shows the memory used in KBytes for the program, the variables, and the gui controls

MM.VER and MM.INFO(VERSION) will both now show the full version including the beta value

e.g this release will give 5.070025
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 1196
Posted: 11:04am 07 Oct 2021
Copy link to clipboard 
Print this post

Oh, that sounds a lot easier. :)
If GUI CONTROLS is set/enabled without first setting MEMORY will it auto-adjust the memory then?
-- Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 1943
Posted: 11:05am 07 Oct 2021
Copy link to clipboard 
Print this post

  matherp said  MM.VER and MM.INFO(VERSION) will both now show the full version including the beta value

e.g this release will give 5.070025


Presumably the release will return 5.07 ?

What would you have done if you were introducing this during the alpha phase ? what will a release candidate return ?

Would an MM.INFO(BUILD) be a better alternative: "a1" ... "aN", "b1" ... "bN", "rc1" ... "rcN", "final" ?

Not trying to be awkward, I just have "some skin in the game" now.

Best wishes,

Tom
CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 1943
Posted: 11:10am 07 Oct 2021
Copy link to clipboard 
Print this post

  thwill said  Presumably the release will return 5.07 ?


... and thus have a lower version number than the betas ... maybe not

Best wishes,

Tom
CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5460
Posted: 11:38am 07 Oct 2021
Copy link to clipboard 
Print this post

  Quote  Presumably the release will return 5.07 ?


The release will be 5.07.01
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 1943
Posted: 11:49am 07 Oct 2021
Copy link to clipboard 
Print this post

  matherp said  
  Quote  Presumably the release will return 5.07 ?


The release will be 5.07.01


So the betas for any development of 5.07.02 will have version numbers 5.0701XX ?

Also does this whole business of representing the version number as a double not hit the issue that IEEE754 does not provide arbitrary precision ?

EDIT: perhaps not, or not in anyway that matters - ignore me ;-)

Best wishes,

Tom
Edited 2021-10-07 21:53 by thwill
CMM2 Welcome Tape, Creaky old text adventures
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 952
Posted: 01:21pm 07 Oct 2021
Copy link to clipboard 
Print this post

@Peter,

I am in the unfavourable position that I have absolutely no experience in GUI controls. And if I have, it all happened without me knowing it. That makes life easy.

Anyway, assume I don't know what I am talking about...

But...as I understand... a GUI control is a button or gauge or indicator or adjustment in the LCD graphics. A single screen GUI with 39 GUI elements seems pretty cluttered, unless you are making a PC keyboard.

Would it be an option to make the default memory map support 39 (2kbyte) GUI elements, as so to lower the barrier for newcomers to GUI controls ?
Once they (we ... me) know how to make 39 GUI controls, we should be educated enough to change to default option memory. Wasting 2k of the 160k is only 1.5%.... Nobody but the die-hards will notice. And die-hards know how to change option memory.

Regards,

Volhout.
If nothing goes right ... turn left
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5460
Posted: 01:56pm 07 Oct 2021
Copy link to clipboard 
Print this post

PicoMiteV5.07.00b26.zip


I've received representations about the problem of a program being lost if it isn't saved after an edit and then there is a power outage or system reset for any reason

b26 addresses this by copying to flash the program every time you exit edit or autosave or LOAD from SDcard (but not FLASH LOAD or FLASH CHAIN for obvious reasons).

In the event of a reset happening you can then restore the last edited program by using the new sub-command FLASH RESTORE BACKUP

In the event of the backup being corrupted you can erase it using FLASH ERASE BACKUP

You should probably execute FLASH ERASE BACKUP after installing this release to make sure the flash area used is clean
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 1196
Posted: 02:12pm 07 Oct 2021
Copy link to clipboard 
Print this post

@Volhout...
If I've got it right, it's actually using 2K out of 80K. You don't get 160K of BASIC space, that's total usable memory. 80K will have your program in it and 80K will have the editor etc. in it.

It looks like
OPTION GUI CONTROLS 10
will give you 10 controls to play with. OPTION LIST will show that you have a total of 78K for program & variables and 2K for GUI controls (they take 52 bytes each, rounded up to the next 2K block, so you can get 39 into 2K).

You can have up to 32 pages of GUI controls (I think) and split the controls over them so you can have plenty of space to play with. :)

--------------------
@Peter
Oh, that's a nice, useful update. :)
Edited 2021-10-08 00:28 by Mixtel90
-- Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 952
Posted: 02:56pm 07 Oct 2021
Copy link to clipboard 
Print this post

Hi Peter,

If you run the "backup" default with option AUTORUN ON than you have exactly mimicked the MX170 behaviour.
Basic would be AUTORUN ON, AUTORUN OFF
Extension would be  AUTORUN 1,2,3,4 to select a flash slot.

Volhout



  matherp said  PicoMiteV5.07.00b26.zip


I've received representations about the problem of a program being lost if it isn't saved after an edit and then there is a power outage or system reset for any reason

b26 addresses this by copying to flash the program every time you exit edit or autosave or LOAD from SDcard (but not FLASH LOAD or FLASH CHAIN for obvious reasons).

In the event of a reset happening you can then restore the last edited program by using the new sub-command FLASH RESTORE BACKUP

In the event of the backup being corrupted you can erase it using FLASH ERASE BACKUP

You should probably execute FLASH ERASE BACKUP after installing this release to make sure the flash area used is clean

Edited 2021-10-08 00:57 by Volhout
If nothing goes right ... turn left
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 952
Posted: 03:03pm 07 Oct 2021
Copy link to clipboard 
Print this post

Dear Peter,

I am sure I have asked this before, but can't remember your answer.
The MX170 has support for a "library". Is this something that can be implemented on the pico at expense of 1 flash slot ? Or is there in the complex mechanism that is inherited from the CMM2 something blocking the library.

Regards,

Volhout


P.S. with regards of the previous post (that I can't edit anymore)
- always run flash restore backup after a reset or cold boot (empty memory won't help you anyway).
- flash erase backup would be called NEW....;)
Edited 2021-10-08 01:08 by Volhout
If nothing goes right ... turn left
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5460
Posted: 03:08pm 07 Oct 2021
Copy link to clipboard 
Print this post

  Quote  Hi Peter,

If you run the "backup" default with option AUTORUN ON than you have exactly mimicked the MX170 behaviour.

Volhout


Your wish is my command


PicoMiteV5.07.00b27.zip

  Quote  The MX170 has support for a "library". Is this something that can be implemented on the pico at expense of 1 flash slot ? Or is there in the complex mechanism that is inherited from the CMM2 something blocking the library.


There is a lot of code to support the library concept that isn't in the PicoMite. I have thought about it but the issue is that the library would be in slow flash rather than RAM so doesn't make much sense
Edited 2021-10-08 01:10 by matherp
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 952
Posted: 03:09pm 07 Oct 2021
Copy link to clipboard 
Print this post

Posts have crossed...

  Quote  P.S. with regards of the previous post (that I can't edit anymore)
- always run flash restore backup after a reset or cold boot (empty memory won't help you anyway).
- flash erase backup would be called NEW....;)

If nothing goes right ... turn left
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5460
Posted: 03:12pm 07 Oct 2021
Copy link to clipboard 
Print this post

Crossed again - see edited post
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 952
Posted: 07:17pm 07 Oct 2021
Copy link to clipboard 
Print this post

@Peter,

What I have tested works, even from autosave the backup is nicely made.
There is one additional feature in this backup process. In making the backup the pico tokenizes, so syntax errors do not require a run to become obvious.

Maybe you could consider at cold boot (powerup) to do a "flash restore backup" anyway if not autorun set. You could keep the flash restore backup never the less. But in that case "flash erase backup" could be called "new".

Volhout
If nothing goes right ... turn left
 
karlelch
Newbie

Joined: 30/10/2014
Location: Germany
Posts: 24
Posted: 12:32pm 10 Oct 2021
Copy link to clipboard 
Print this post

Hi

Pimoroni has a nice ST7789 based display for the pico (see https://shop.pimoroni.com/products/pico-display-pack). Unfortunately, the command `OPTION LCDPANEL ST7789, OR, DC, RESET, CS` does not support the correct resolution, which is 240x135 instead of 240x240. How difficult would it be to add support for this display?

Thanks,
Thomas
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 5460
Posted: 12:54pm 10 Oct 2021
Copy link to clipboard 
Print this post

Its there

OPTION LCDPANEL ST7789_135, OR, DC, RESET, CS

also supports ST7789 320x240 displays

OPTION LCDPANEL ST7789_320, OR, DC, RESET, CS
 
karlelch
Newbie

Joined: 30/10/2014
Location: Germany
Posts: 24
Posted: 03:20pm 10 Oct 2021
Copy link to clipboard 
Print this post

Ah - thanks! I did not see this in the documentation.

Btw. Are there any plans to put the code on a platform like GitHub?
 
     Page 1 of 3    
Print this page
© JAQ Software 2021