element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
microbit
  • Learn
  • Learning Center
  • STEM Academy
  • microbit
  • More
  • Cancel
microbit
microbit Forum Problem with ISP on micro:bit
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join microbit to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 13 replies
  • Subscribers 50 subscribers
  • Views 3599 views
  • Users 0 members are here
  • shift register
  • micro:bit
  • digital write
  • python
  • bbc micro:bit
  • spi
  • tempus fugit
  • mu editor
  • chip select
  • protocol
  • spi not working
Related

Problem with ISP on micro:bit

balearicdynamics
balearicdynamics over 7 years ago

I have a strange issue with the micro:bit that I have no idea by what it can depends. Maybe also a behavioural detail I have not considered and I am expecting something that it is normal does not happens.

 

The scenario

For more detail on how the project is designed take a look to the blog posts on Tempus fugit...

 

Tempus Fugit... Part 1: 1978 a.d.  project intro

Tempus Fugit... Part 2: 2018 a.d. the components and the logic of the project

Tempus Fugit... Part 3: micro:bit Interfacing 5V Logic the first issue: interfacing 3.3 logic signals from micro:bit to 5V logic on IC. Tested and solved

Tempus Fugit... Part 4: micro:bit 5V SPI adopting the solution discussed in the previous blog post to my use case: 7-segments LED controller via SPI protocol.

 

The problem

Hardware seems working properly; with simple programs to control the pins involved by the SPI protocol (13, 14, 15 on the micro:bit) and testing with the oscilloscope bon both sides 3.3 V (output connector from the micro:bit) and 5V (input connection to the IC) these works perfectly and there are no problems. Then, I tried to implement in Python using MU the SPI protocol and on the same pins controlling with the oscilloscope nothing happens. To do this I have used the Python library to control the specific IC but none at all. I am not interested in this moment to see the display working. What I just need to understand is what can be the issue that is blocking the SPI protocol to work correctly, also when the test program runs on on the micro:bit without the controlled circuit connected to avoid interferences. The same behaviour happens on a second micro:bit board, while the digital output setting of the pins with the test program continue working; I can suppose that there is not any hardware problem.

 

Any suggestion and idea is more than welcome image

 

Enrico

  • Sign in to reply
  • Cancel

Top Replies

  • jc2048
    jc2048 over 7 years ago +4
    This code works with the Python Editor on their website # Add your Python code here. E.g. from microbit import * buf = bytearray(1) spi.init() while True: buf[0]=0xa4 spi.write(buf) sleep(20) these…
  • stevesmythe
    stevesmythe over 7 years ago +4
    Hi Enrico I have used SPI with the micro:bit a couple of times - with two different 7-seg displays. I can't see from your project what SPI controller IC you are trying to control. If you could post the…
  • balearicdynamics
    balearicdynamics over 7 years ago in reply to stevesmythe +4
    Hello Steve, Thank you for your support. Now it wkrkw and tomktrow I will setup the software. Enrico
  • jc2048
    jc2048 over 7 years ago

    This code works with the Python Editor on their website

     

    # Add your Python code here. E.g.
    from microbit import *
    
    buf = bytearray(1)
    
    spi.init()
    
    while True:
        buf[0]=0xa4
        spi.write(buf)
        sleep(20)

     

    these are the output signals (yellow=clock,blue=data)

    image

     

     

    That's with the default init settings.

     

    But that's with the SPI in the microbit module. I don't know if working with MU is the same or whether you'd need to do something different.

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • Cancel
  • balearicdynamics
    balearicdynamics over 7 years ago in reply to jc2048

    Hi John,

     

    thank you for the experiment. I have done the same and got always the same result I got with MU. This is just an editor specific for micro:bit working on local files but includes all the libraries. Anyway, with the standard editor of microbit.org with your code, downloaded and sent to the board nothing happens. In both cases, using the micro:bit with the controller connected and with a different micro:bit board without any circuit. image

     

    As the pin themselves works fine when I use write_digital(), I suppose that there is something or some setting I am not making correctly but I have no idea what can it be done.

     

    Enrico

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
  • dougw
    dougw over 7 years ago

    The only thing I do get SPI working with mu is run an init command during initiallization:

    spi.init(baudrate=1000000, bits=8, mode=0, sclk=pin13, mosi=pin15, miso=pin14)

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
  • balearicdynamics
    balearicdynamics over 7 years ago in reply to dougw

    Thank you Doug, I hope this is my mistake and not something stranger. I'll try this afternoon and let you know.

     

    Enrico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • stevesmythe
    stevesmythe over 7 years ago

    Hi Enrico

     

    I have used SPI with the micro:bit a couple of times - with two different 7-seg displays. I can't see from your project what SPI controller IC you are trying to control. If you could post the datasheet for that component it would be helpful.  In addition to the SPI controls, there is usually another pin called chip select or CS on the controller IC to "latch" the data to the display. To send anything to the display you need to take the chip select pin (P0) low, then send the data, then take the chip select pin high again.Here is my micropython code for a MAX7219 controller.

     

     

    from microbit import *

    # setup SPI

    spi.init(baudrate=1000000, bits=8, mode=0, sclk=pin13, mosi=pin15, miso=pin14)

    # initialisation code

     

    pin0.write_digital(0)

    spi.write(b'\x0f\x00')  # enable normal mode and disable test mode

    pin0.write_digital(1) # latch data

    sleep(300)

     

    With best wishes

     

    Steve

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • Cancel
  • balearicdynamics
    balearicdynamics over 7 years ago in reply to stevesmythe

    Hello Steve,

    thank you very much for your suggestions. I will try immediately. You mention pin0. As far as I know, there is no difference between pin0 or any other digital I/O pin or for some reason that I don't know it is absolutely necessary to use this pin? The reason is that I will use pin0 to generate audio frequency and as far as I know only pin0 can do this easily in the micro:bit.

     

    I am aware of the CS pin (number 12 on the 7219) asI am using the same IC. Now I will test your suggested program and see what happens with pin0. I will update you shortly.

     

    Enrico

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • stevesmythe
    stevesmythe over 7 years ago in reply to balearicdynamics

    Sorry, I chose P0 at random as the CS pin (you can use any unused pin). In your case, just modify my code but connect CS  on the 7219 to (say) P12 on the micro:bit and change my code to:

     

    pin12.write_digital(0) etc etc.

     

    The MAX7219 is quite complicated to get fully working (it has many "modes") but my code snippet will get "test mode" working easily. I have a blog post here that goes into more detail about using this controller with the micro:bit.

     

    Good luck.

     

    Steve

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • balearicdynamics
    balearicdynamics over 7 years ago in reply to stevesmythe

    Hello Steve,

     

    Thank you for your support. Now it wkrkw and tomktrow I will setup the software. imageimage

     

    Enrico

    image

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • Cancel
  • stevesmythe
    stevesmythe over 7 years ago in reply to balearicdynamics

    Hi Enrico

     

    That's great news! "Test mode" looks good image  I look forward to following your project to completion.

     

    With best wishes

     

    Steve

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • balearicdynamics
    balearicdynamics over 7 years ago in reply to stevesmythe

    Hi Steve,

     

    thank you again. I took a look at the link on your blog and it seems very complete and detailed, I think it is very useful for my project.

     

    Cheers, Enrico

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube