Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:10 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 : 4.7b27 SPI speeds

Author Message
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2950
Posted: 02:16pm 19 Nov 2015
Copy link to clipboard 
Print this post

GDay Geoff, All,

Curtis (JustPlayin) mentioned to me that the SPI command seems to be a bit `wonky' so I decided to connect up my Cro and I have found that (with 4.7 b27 at least) we get these results

NOTE these are with a CPU 48 command set at the beginning of the code (should be able to have a max of 12MHz, I believe). Readings were done on a 28pin uMite

Setting Measured Pulse

1MHZ 450ns 2.2MHz
2 120ns 8.3MHz
3 135ns 7.4MHz
4 80ns 12.5MHz
5 40ns 25MHz
6 40ns 25MHz
6 40ns 25MHz
7 40ns 25MHz
8 40ns 25MHz
9 340us 2.9kHz
10 340us 2.9kHz
11 340us 2.9kHz
12 340ns 2.9kHz

I also had, at times, some difficulty in locking in and readings did vary slightly at times but the general gist seems to be the same.

I used the SPI CLK pin(25) as the point to measure referenced to GND.

OK I know ver 5.0 is out and that is the next step to repeat these tests with Ver 5, but I am not in a position to do that until Tomorrow.

Can anyone else repeat these results (Or refute them)?

The command where we set the SPI speed is as such:

SPI Open 8000000, 3, 16 ' set for 8MHz


Regards,

Mick





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

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 05:57pm 19 Nov 2015
Copy link to clipboard 
Print this post

I tried with a 44pin 170 and MMBasic V5.0
CPU 48

Speed in MHz, clock period, clock MHz

1, 1000, 1
2, 500, 2
3, 332, 3
4, 252, 4
5, 164, 6
6, 164, 6
7, 124, 8
8, 124, 8
9, 82, 12
10, 82, 12
11, 82, 12
12, 82, 12

I measured the period rather than the pulse width. It gives a more accurate reading on my old CRO.

Jim
VK7JH
MMedit
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2950
Posted: 07:10pm 19 Nov 2015
Copy link to clipboard 
Print this post

Thanks Jim,

Different, Better but still shows a couple of `funnies' there.

Tomorrow I will update to Ver 5 and try it again.

I measured the period as well on my 50MHz LCD Cro...

I did get some irregularities as my Cro prints the period and Frequency but on some of the `readings' the reported readings didnt marry up to the timebase setting I was using.

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: 09:57pm 19 Nov 2015
Copy link to clipboard 
Print this post

  bigmik said  . . . . I have found that (with 4.7 b27 at least)


Welcome back Mick
b27 shows how long you've been 'otherwise occupied'!!

Unfortunately no scope here to test this but I have had some strange things with my SPI2 (but only me so it is a 'local' problem here).

I think I might have to get hold of a scope now (but total lack of space here to store it).

@matherp (or anyone else) What is the maximum speed signal that your MicroMite scope can display (with all your latest mods to hardware/software)?

WW
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 10:03pm 19 Nov 2015
Copy link to clipboard 
Print this post

  Quote  Better but still shows a couple of `funnies' there.


The SPI speed works by dividing down the system clock scaled by 2

So the maximum speed at a clock rate of 48MHz is 24MHz. This is then further scaled using a 9-bit register.

Divide by 2 to get 12MHz, 3 gives 8MHz, 4 give 6MHz, 5 gives 4.8MHz, 6 gives 4Mhz etc.

These are the only possible values. The SPI command picks the nearest to the requested value out of a limited range of possibilities.

There was a bug in the SPI clock code that was fixed in a relatively recent beta and in V5 - hence the issues with b27Edited by matherp 2015-11-21
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2950
Posted: 10:33pm 19 Nov 2015
Copy link to clipboard 
Print this post

Hi Phil, All,

  WhiteWizzard said  
Welcome back Mick
b27 shows how long you've been 'otherwise occupied'!!


Yes the busy time left me early last week but then the `dreaded lurgy' caught up with me and I cant seem to shake this rasping cough... Done my antibiotic course but may need to see the doc again and get a repeat dose.

  matherp said  
There was a bug in the SPI clock code that was fixed in a relatively recent beta and in V5 - hence the issues with b27


Thanks Peter, I guessed that may have been the case.. I will update with ver 5 tomorrow, unfortunately I ran out of time to do it today as I had to go for my `night shift' anyway I will get back to all here.

Yes I am back, well I never really left as I did scan through the posts to try to keep abreast of things but I couldnt put much time into replies and questions then..
Just had enough time to lose my bet with Grogster.


Regards,

Mick


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

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2950
Posted: 04:30am 20 Nov 2015
Copy link to clipboard 
Print this post

Hi All,

I have updated to Ver 5.0 and all is as Jim has reported..

I tested further and found from setting 13 through to 24 gives 24MHz.

This agrees with what Peter stated except that it selects the next HIGHEST valid setting not the NEAREST..
As can be seen with 4.8MHz, selecting 5MHz gives 6MHz to get 4.8MHz requires a selection of greater than 4 but less than 4.8MHz

Anyway all good now, thank you all who assisted .

regards,

Mick


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

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 03:53pm 20 Nov 2015
Copy link to clipboard 
Print this post

Thanks Peter for the explanation.

To see the likely results when you are looking for a specific SPI clock rate, this program should do the job:

CPUclock = 48 : GOSUB rates
CPUclock = 40 : GOSUB rates
CPUclock = 20 : GOSUB rates
CPUclock = 10 : GOSUB rates
END

rates:
PRINT "CPU clock = ",CPUclock
FOR n = 1 TO CPUclock/4
PRINT n," ",CPUclock/2/INT(CPUclock/2/n)
NEXT n
PRINT ""
RETURN


Output for 48MHz clock:
CPU clock = 48
1 1
2 2
3 3
4 4
5 6
6 6
7 8
8 8
9 12
10 12
11 12
12 12


The manual states 'The maximum is one quarter the CPU speed' so I am not sure about the reliability at anything greater than 1/4.

Jim
VK7JH
MMedit
 
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