Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

MicroPython on PSoC™

lking
Moderator
Moderator
Moderator
10 questions asked 25 sign-ins 5 questions asked

MicroPython on PSoC™

I was looking for an answer to a question posted on the Hackster.io community site concerning support for Python on an Infineon PSoC board. My initial web search led me to Zerenth.com, where I found out that unfortunately Zerynth no longer supports PSoC. Later I discovered that there is an incomplete port of MicroPython on the web:

Anyone can give it a try if they have a CY8CPROTO-062-4343W around and 10 min -> https://ifx-micropython.readthedocs.io/en/latest/psoc6/intro.html

Well, if there is a Github repo and documentation I might as well give it a try and see what MicroPython can do.

My experience with Python is quite limited; I have made small changes to existing Python programs, but I have never developed a full system in Python. Moreover, my experience with MicroPython is even more limited, since I have never even tried it on any development board.

The obvious place to start with any new programming language is with the classics: Hello_World, and Blinky. Let’s see if I can create a MicroPython program that prints Hello World on the screen, and blinks the LED on the board.

Of course, it is normally considered ‘cheating’ to read the documentation before trying and failing, but since I have no idea what I am doing, I suspect that reading the provided documentation is the best place for me to start. Maybe the documentation will have a Hello_World or Blinky program.

Starting here: https://ifx-micropython.readthedocs.io/en/latest/psoc6/intro.html I checked the supported board list. The list is really short (one board, CY8CPROTO-062-4343W), but fortunately that is a board I happen to have on my desk. The getting started guide has Linux instructions so, since I normally do all of my development under Linux, I fired up a VM with Ubuntu 22.04. Here is what I did to get started:

𝚖𝚔𝚍𝚒𝚛 𝚖𝚒𝚌𝚛𝚘𝚙𝚢𝚝𝚑𝚘𝚗
𝚌𝚍 𝚖𝚒𝚌𝚛𝚘𝚙𝚢𝚝𝚑𝚘𝚗
𝚌𝚞𝚛𝚕 -𝚜 -𝙻 𝚑𝚝𝚝𝚙𝚜://𝚛𝚊𝚠.𝚐𝚒𝚝𝚑𝚞𝚋𝚞𝚜𝚎𝚛𝚌𝚘𝚗𝚝𝚎𝚗𝚝.𝚌𝚘𝚖/𝚓𝚊𝚎𝚗𝚛𝚒𝚐-𝚒𝚏𝚡/𝚖𝚒𝚌𝚛𝚘𝚙𝚢𝚝𝚑𝚘𝚗/𝚙𝚘𝚛𝚝𝚜/𝚙𝚜𝚘𝚌𝟼/𝚝𝚘𝚘𝚕𝚜/𝚙𝚜𝚘𝚌𝟼/𝚖𝚙𝚢-𝚙𝚜𝚘𝚌𝟼.𝚜𝚑  > 𝚖𝚙𝚢-𝚙𝚜𝚘𝚌𝟼.𝚜𝚑𝚌𝚑𝚖𝚘𝚍 +𝚡 𝚖𝚙𝚢-𝚙𝚜𝚘𝚌𝟼.𝚜𝚑
./𝚖𝚙𝚢-𝚙𝚜𝚘𝚌𝟼.𝚜𝚑 𝚚𝚞𝚒𝚌𝚔-𝚜𝚝𝚊𝚛𝚝

And as expected my VM told me that curl was not installed. After installing curl I tried again. Things happened, beautiful ASCII art appeared:

yughjkl.PNG

 

After connecting the board hitting the ANY KEY (apparently the spacebar is not an ANY KEY, I had to press the ENTER key) many more things happened, and code was installed onto my board:

lking_1-1674476381502.png

I wasn’t fooled by the ‘any key’ this time, I pressed the enter key and many more things happened, then the Arduino Lab for MicroPython popped up on my screen, just like the instructions said would happen.

lking_2-1674476381708.png

Pressing the connect button told me that /dev/ttyACM0 was available, clicking on the text opened the port and the console started up:

lking_3-1674476381874.png

I won’t bore you with the rest of the details, but when I tried writing a Blinky program I discovered that the sleep function has not been implemented yet (just like the documentation says), the following program runs, but VERY quickly.

from time import sleep
from machine import Pin

p1 = Pin("P13_7")   # LED pin for CY8CPROT-062-4343W
p1.init(Pin.OUT)

print("Hello World")
for i in range(0, 100):

    p1.off()
    sleep(1.0)
    p1.on()
    sleep(1.0)

I am looking forward to the next release. Hopefully the sleep function will work and the board will be able to do more useful things. 😉 

0 Likes
59 Views