What is software SPI speed for various OSC speeds?


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default What is software SPI speed for various OSC speeds?

    Hello.
    I'm building a project, very fast counter using MAX7219 and 4 digit 7 segment display. It's image will be filmed by high speed camera. So I'm curious, since picbasic communicates with MAX7219 via software SPI, what the best speed of display update, in frames per second, I can get? Say MAX7219 is running in BCD decode mode and OSC is 8Mhz at 16F887.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: What is software SPI speed for various OSC speeds?

    The manual states that the clock runs at about 50Khz depending on oscillator, they're probably basing that figure on a 4MHz oscillator. At 8MHz I would expect around 100Khz.

    I'm currently using SHIFTOUT on a device running at 64MHz and just measured the clock frequency to around 320kHz. The reason it doesn't scale 100% linearly with oscillator frequency is, I guess, that they're always holding the clock active for 2us (or more if you set it).

    If you need more than 300kHz then you need to move to hardware SPI. Clock frequency isn't everything though.

  3. #3
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: What is software SPI speed for various OSC speeds?

    This just will be the visual counter, it will show on display numbers from 1 to 9999. The question is, how fast this update can be made.
    I'd prefer it to count from 1 to 9999 in 0.1-0.2 seconds.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: What is software SPI speed for various OSC speeds?

    Never used the MAX7219 so correct me if I'm wrong but reading the datasheet it looks like for each digit on the display you need to shift out 16bits. 4 digits x 16bits = 64bits.
    If the SPI clock is 100kHz then shifting out those 64bits takes 6.4us meaning the the absolute best you will ever get (not taking ANY processing into account) is 1500 updates per second while you want it to display 10000 different values in 0.2 seconds (50000 updates per second).

    Also, and perhaps I've misunderstood this but, you do realise that the display is multplexed right?
    If you're trying to film it actually displaying all values between 0 and 9999 in 200ms then I don't think that's going to happen, no matter how fast you shift out the data.

    The datasheet specifies the scanrate to be 800Hz meaning the display refreshes 800 times per second with all 8 digits being used. During your 200ms "window" the display readraws itself 160 times and you expect it to able to show 10000 different values during that time?

    Granted, with only 4 digits and using the scan-limit register you can make it update the display faster but even if it scans a 4 digit display 1600 times per second you're not even CLOSE to being able to "show" 10000 unique values in 200ms.

    /Henrik.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: What is software SPI speed for various OSC speeds?

    If you're trying to film it actually displaying all values between 0 and 9999 in 200ms then I don't think that's going to happen, no matter how fast you shift out the data.
    Nice camera 50000 frames / sec

    my tm1637 code can load the 4 digits in just under 50uS [40bits] on pic18@64mhz /16mhz mssp spi clock, you could could not maintain that rate for a 0-9999 count that would have its own overheads to add in. as henrik pointed out the multiplexing would be the limiting factor there too i think.
    Warning I'm not a teacher

  6. #6
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: What is software SPI speed for various OSC speeds?

    Well, MAX7219 datasheet says 10mhz clock, that is way faster than 50khz, so I guess, since it supports that, this means it can also display with that speed, right?

    Regarding the current project, considering relatively low number of pins needed to drive 4 digits (28 pins) without any multiplexing or whatever, I think, it'll be better, if I control segments directly from MCU. As I have calculated, 1 port high/low or latch high/low with 4mhz clock, is possible at 1mhz frequency. Say I have to update altogether, this means it will be 28 times slower, about 35khz, which is 35000 fps. So if I up clock to 8mhz, I can do 50khz, with some overhead for counter code and so on.

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: What is software SPI speed for various OSC speeds?

    Well, MAX7219 datasheet says 10mhz clock, that is way faster than 50khz, so I guess, since it supports that, this means it can also display with that speed, right?
    No, why do you think that? All it means is that the chip can load the information about what it should display at that rate, it takes a lot longer for it to actually "render" the information on the display.

    From the datasheet:
    The scan-limit register sets how many digits are displayed, from 1 to 8. They are displayed in a multiplexed manner with a typical display scan rate of 800Hz with 8 digits displayed.
    If fewer digits are displayed, the scan rate is 8fOSC/N, where N is the number of digits scanned.
    So with 4 digits in use the display is updated at a rate of 8*800/4=1600 times per second.

    If you really do need the display to update 50000 times/second I'd suggest to use some latching driver chips (BCD to 7-segement or just plain old latches). The HEF4543 would be a good candiate I think.
    If you drive the digits directly with the PIC you need write to 4 different output/latch registers sequentially so there's a slight risk it will actually show up on camera since the four digits won't actially update at the same time. Like when going from 0099 to 0100 it MIGHT show up on camera like 0099, 0090, 0100 etc depending on the order in which you update the digits. If you use external latches you can preset the data and then latch it in all at once - bam.

  8. #8
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: What is software SPI speed for various OSC speeds?

    Thanks, I was thinking about that, but just with external transistor, which will drive common pin for 7 segment....

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: What is software SPI speed for various OSC speeds?

    So if I up clock to 8mhz, I can do 50khz, with some overhead for counter code and so on.
    1k if you're lucky imo
    Warning I'm not a teacher

  10. #10
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: What is software SPI speed for various OSC speeds?

    Tried some lower speeds with MAX7219 and scan rate definitely causes issues - the moment digits are just going off being registered by high speed camera, so it is hard to guess what is displayed right now. Already noticeable at 5000fps.

Similar Threads

  1. SPI Commands Operating Speed
    By gunayburak in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 4th December 2016, 01:56
  2. 12F683, 12LF1840 - Port ON/OFF speeds are different!
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 4th February 2015, 15:35
  3. Software based SPI For use on Nordic NRF24L01
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th April 2012, 02:49
  4. Pulsin ir receiver and osc speeds
    By jimseng in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 24th March 2012, 20:12
  5. Replies: 4
    Last Post: - 16th May 2008, 15:35

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts