Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:14 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 : Latest MMbasic Language Manual

Author Message
tritonium
Newbie

Joined: 16/06/2018
Location: United Kingdom
Posts: 22
Posted: 12:02am 14 Sep 2018
Copy link to clipboard 
Print this post

Hi

I have been playing with mmx170 and having great fun.
I have a 4 digit led 8X8 matrix display using MAX 7219 and have it using a bit bang spi I've worked out for myself. It works fine but slowly.
So time to use the MMBASIC built in spi routines.
Consulting the MMBasic Language Manual ver 4.5 I'm told to -

SPI( rx, tx, clk[, dat[,speed]] ) 'FOR CMM & MM versions

Sends and receives a byte using the SPI protocol with MMBasic as the
master (ie, it generates the clock).
‘rx’ is the pin number for the data input (MISO)
‘tx’ is the pin number for the data output (MOSI)
‘clk’ is the pin number for the clock generated by MMBasic (CLK)
‘dat’ is optional and is an integer representing the data byte to send over
the data output pin. If it is not specified the ‘tx’ pin will be held low.
‘speed’ is optional and is the speed of the clock. It is a single letter
either H, M or L where H is 3MHz, M is 500 KHz and L is 50 KHz.
Default is H.

See Appendix D for a full description.

Appendix D example

Example
The following example will send the command 80 (hex) and receive two bytes from the slave SPI device.
Because the mode, speed and number of bits are not specified the defaults are used.
SETPIN 18, 2 ‘ set rx pin as a digital input
SETPIN 19, 8 ‘ set tx pin as an output
PIN(20) = 1 : SETPIN 20, 8 ‘ set clk pin high then set it as an output
PIN(11) = 1 : SETPIN 11, 8 ‘ pin 11 will be used as the enable signal

PIN(11) = 0 ‘ assert the enable line (active low)
junk = SPI(18, 19, 20, &H80) ‘ send the command and ignore the return
byte1 = SPI(18, 19, 20) ‘ get the first byte from the slave
byte2 = SPI(18, 19, 20) ‘ get the second byte from the slave
PIN(11) = 1 ‘ deselect the slave

It brought up all sorts of errors-
so I hunted around for someone elses code that uses spi and sure enough
This works.

option explicit
'mx170 spi pins
const dat = 3 'tx
const cs = 16
const clk = 25
const rx = 14

setpin clk, oout
setpin dat, oout
setpin cs, oout
setpin rx, din

pin(cs)=1
pin(dat)=0
pin(clk)=0

SPI OPEN 2000000,0,8

Code here to generate data etc.......................

Subroutine to send 16 bits
sub spis (v)
local integer xl,vl
vl=v>>8 '16 bit send 8 at a time MSb first
pin(cs) = 0
SPI WRITE 1,vl
vl=v and 255
SPI WRITE 1,vl
end sub

SO (at last) my question is- Is there a more up to date language manual please- I've hunted around and version 4.5 appears to be the latest, but clearly isn't.

Thanks
Dave

 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 12:20am 14 Sep 2018
Copy link to clipboard 
Print this post

There are a lot of differences between the Maximite and the Micromite.

You get the latest version of the manual form the same place as the firmware.
http://geoffg.net/micromite.html
Scroll down to the bottom and for the MX170, the manual is the micromite one, not the Micromite Plus.
It is also included in the ZIP file that has the V5.04.09 firmware.

Jim
VK7JH
MMedit
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2950
Posted: 06:54am 14 Sep 2018
Copy link to clipboard 
Print this post

Hi Tritonium,

  tritonium said  
I have a 4 digit led 8X8 matrix display using MAX 7219 and have it using a bit bang spi I've worked out for myself. It works fine but slowly.


Curtis (Username Justplayin) and I have a 3 colour (red/Green LED -- and ORANGE with both LEDs on). Curtis did a great job with C routines to get quite a good display with special effects going (I have some crappy video captures but they don't show how good the display actually is)

If you are interested Check out the directory here.

Mik-Matrix

The link to Dontronics is not valid but I can supply the PCBs if interested or Curtis may still have some available and he is in the USA so more local than me.

Kind Regards,

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

Joined: 05/04/2013
Location: United Kingdom
Posts: 2944
Posted: 07:05am 14 Sep 2018
Copy link to clipboard 
Print this post

  tritonium said  ... It works fine but slowly.


Hi Dave,

When you say 'slowly' what is it you are aiming for? One of my very first MM designs (on an MX150) was a Digital Clock based on five 8x8 MAX7219 modules and it works great. However, if you are after 50Hz video animation then yes, it would be 'slow'.

You have me curious . . .

See BigMik's application that he refers to above - it may help you!
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2944
Posted: 07:22am 14 Sep 2018
Copy link to clipboard 
Print this post

I have extracted the relevant parts of my GPS clock code (the SPI bits that do the 'important stuff' driving the MAX7219 modules) and pasted below.

Maybe this will help you too?

WW



''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' GPS CLOCK
' WhiteWizzard July 2014
' Based on Geoff Graham's code, March 2014
'
' Demonstration of the MAX7219 SPI driven
' This program will get the time from a U-Blox 7 GPS module, add the timezone
' and daylight saving then display on a 40x8 LED Matrix
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'==================================================
' MAX7219 LED DISPLAY for 44pin µMite *
'=================================================

SPI OPEN 3000000, 3, 16

dim m(5) 'five Matrix blocks - using Pins 1 to 5 as the 'ChipSelect'
for i=1 to 5: m(i)=i : setpin m(i),dout: next i ' set pins as outputs


'----------------------MAIN----------------------------
M7219_INIT

'=====================================================
Sub M7219_INIT
for i = 1 to 5
AA=SPI(&H0C00): Pulse m(i),1 'SHUTDOWN
AA=SPI(&H0900): Pulse m(i), 0.1 'BCD DECODE ALL DIGITS
RAA=SPI(&H0A00): Pulse m(i), 0.1 'BRIGHT 17/32%
AA=SPI(&H0B07): Pulse m(i), 0.1 '8 DIGITS
AA=SPI(&H0F00): Pulse m(i), 0.1 'TESTS OFF
AA=SPI(&H0C01): Pulse m(i), 1 'RUN
next i
ERASE_ALL
End Sub

'--------------------------------------------------------------
Sub ERASE_ALL
Local I,AA
for x=1 to 5
For I=1 To 8
AA=SPI(&H0000+I*256): Pulse m(x),1
Next I
next x
End Sub

'--------------------------------------------------------------
sub DispData
local AA
'First matrix
AA=spi(256+DispStrt(1)):pulse m(1),0.1 'send first row (or column?) Binary Pattern stored in DispStrt() array
AA=spi(512+DispStrt(2)):pulse m(1),0.1 'send second row (column?)
AA=spi(768+DispStrt(3)):pulse m(1),0.1 'send third . . . . .
AA=spi(1024+DispStrt(4)):pulse m(1),0.1
AA=spi(1280+DispStrt(5)):pulse m(1),0.1
AA=spi(1536+DispStrt(6)):pulse m(1),0.1
AA=spi(1792+DispStrt(7)):pulse m(1),0.1
AA=spi(2048+DispStrt(8)):pulse m(1),0.1

AA=spi(256+DispStrt(9)):pulse m(2),0.1
AA=spi(512+DispStrt(10)):pulse m(2),0.1
AA=spi(768+DispStrt(11)):pulse m(2),0.1
AA=spi(1024+DispStrt(12)):pulse m(2),0.1
AA=spi(1280+DispStrt(13)):pulse m(2),0.1
AA=spi(1536+DispStrt(14)):pulse m(2),0.1
AA=spi(1792+DispStrt(15)):pulse m(2),0.1
AA=spi(2048+DispStrt(16)):pulse m(2),0.1

AA=spi(256+DispStrt(17)):pulse m(3),0.1
AA=spi(512+DispStrt(18)):pulse m(3),0.1
AA=spi(768+DispStrt(19)):pulse m(3),0.1
AA=spi(1024+DispStrt(20)):pulse m(3),0.1
AA=spi(1280+DispStrt(21)):pulse m(3),0.1
AA=spi(1536+DispStrt(22)):pulse m(3),0.1
AA=spi(1792+DispStrt(23)):pulse m(3),0.1
AA=spi(2048+DispStrt(24)):pulse m(3),0.1

AA=spi(256+DispStrt(25)):pulse m(4),0.1
AA=spi(512+DispStrt(26)):pulse m(4),0.1
AA=spi(768+DispStrt(27)):pulse m(4),0.1
AA=spi(1024+DispStrt(28)):pulse m(4),0.1
AA=spi(1280+DispStrt(29)):pulse m(4),0.1
AA=spi(1536+DispStrt(30)):pulse m(4),0.1
AA=spi(1792+DispStrt(31)):pulse m(4),0.1
AA=spi(2048+DispStrt(32)):pulse m(4),0.1

AA=spi(256+DispStrt(33)):pulse m(5),0.1
AA=spi(512+DispStrt(34)):pulse m(5),0.1
AA=spi(768+DispStrt(35)):pulse m(5),0.1
AA=spi(1024+DispStrt(36)):pulse m(5),0.1
AA=spi(1280+DispStrt(37)):pulse m(5),0.1
AA=spi(1536+DispStrt(38)):pulse m(5),0.1
AA=spi(1792+DispStrt(39)):pulse m(5),0.1
AA=spi(2048+DispStrt(40)):pulse m(5),0.1

end sub
Edited by WhiteWizzard 2018-09-15
 
tritonium
Newbie

Joined: 16/06/2018
Location: United Kingdom
Posts: 22
Posted: 12:06am 15 Sep 2018
Copy link to clipboard 
Print this post

Hi
Thanks for your interest.

@TassyJim
Yep thanks- thats the manual I needed (and actually had!!!) But I went to
MMBasic.com
Downloads
MMBasic Manual
and got MMBasic Language Manual Ver 4.5
That I thought was just what I was looking for and ignored the rest!!
It does say though-
Throughout this manual Maximite or MM refers to the original monochrome Maximite family..... etc
So if I guess micromite and maximite equated to the same in my aging brain- anyway I'm all set up now -thanks, Micromite manual Ver 5.04 it is.

@bigmik
Wow thats some project- enjoyed the video- must have been a labour of love!! Takes me back a couple of decades when I was playing with 8051's or 2's (can't remember, atmel I think) and made a single red/green 8X8 module with an 8051 and a '138 and a couple transistors and battery to make pretty patterns. I had forgotten til now. Must see if I can find it (never throw anything away).

@WhiteWizzard(a)
Well.
My program was just a 4 digit counter displayed on the leds counting from 0 to 9999.
I say slow because I could see the ripple as the rows updated and it wouldn't count faster than about 3 per second (I think- will check), which seemed very slow compared with bit banging on another processor (but in compiled Basic so not at all comparable). I knew there was a built in SPI hardware so wanted to compare- and sure enough its chalk and cheese- built in is the way to go. I dont actually have a 'use' for anything I build its all just for amusement- I look around e-bay- see something that takes my fancy (often advertised for the 'arduino'- but thats ok- makes it cheap!), and get the manual and interface it and move on.

I probably wouldn't have the staying power to go to the extent BigMik did with his display!- once something works I usually lose interest and move on to the next challenge.

(b)
Your GPS CLOCK code looks interesting, thanks for posting.
It seems you address each matrix individually with 5 'selects'.
The units I am using come in a block of four-
https://www.ebay.co.uk/itm/MAX7219-Dot-led-matrix-MCU-control-LED-Display-module-for-Arduino-Raspberry-Pi/332624530000?e pid=22009138082&hash=item4d71f78a50:g:rNcAAOSwyXFaoNxe
-and they are all linked serially, the output from the first feeds the second and a single 'select' latches them all in, so 64 bits clocked in for one row, (row address byte + data byte times 4 = 8 bytes) and so 64 bytes for the entire block.
64 bytes= 512 clocks- so how fast can you 'bit bang' that?- not very it seems.
Also I have 4 of these and I was going to make a 32X32 block and so that would be four times slower (or 1 quarter as fast....) which would be painful to watch updating.

Its all just for fun- and the built in spi is super fast so no problems.
I'm still learning.
Oh I do like the BASIC language!
Thanks again
Dave






 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2950
Posted: 01:20am 15 Sep 2018
Copy link to clipboard 
Print this post

Hi Dave,

All of the hard work was done by Justplayin (Curtis) here is a link to his initial work that was the catalyst for the Mik-Matrix.

Dot-Matrix Thread

His initial code will probably do exactly what you are trying to achieve now.

As I said it was 99% Curtis's effort. All I did was create a PCB design to suit his requirements.. I can't program my way into a wet paper bag. But PCBs I can do.

Good luck with your efforts and contact Curtis if you need more details I am sure he will be glad to help..

Kind Regards,

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

Joined: 16/06/2018
Location: United Kingdom
Posts: 22
Posted: 11:58am 15 Sep 2018
Copy link to clipboard 
Print this post

@bigmik

  Quote  His initial code will probably do exactly what you are trying to achieve now.


Ok thanks- will keep that in the bag for later until 'after' I get mine going- If I were to cut paste the answer then that would defeat the whole point of waking up in the morning. Its wrestling with the data sheets and hardware and code that is the point for me. I was just trying to find the correct coding syntax for my particular processor, since the one I had was clearly the wrong one.
I have a whole pile of breakout boards I have interfaced and coded for, on another processor and wanted to try them out with the micromite.
Its fun- especially with the friendly folk here to keep me on the straight and narrow.

Dave
 
Justplayin

Guru

Joined: 31/01/2014
Location: United States
Posts: 328
Posted: 05:46pm 15 Sep 2018
Copy link to clipboard 
Print this post

  bigmik said  
All of the hard work was done by Justplayin (Curtis) here is a link to his initial work that was the catalyst for the Mik-Matrix.

Dot-Matrix Thread


I wrote that stuff? The code evolved so much since those first initial test programs!

One thing I'm fairly sure of is my current code for mono colored matrix modules most likely will not work on a 4-digit board. The original code will probably work though but it is hindered by the speed of the MX170. Later versions of the code require the 8x8 LED matrix modules to be rotated 90 degrees which allows for easier manipulation of the data for scrolling.

--Curtis
I am not a Mad Scientist...  It makes me happy inventing new ways to take over the world!!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025