ARM:0012 STM32CubeMX – USB HID mouse

Next canned project for STM32F103 MCU using the cube- USB HID mouse. HID (human interface device) means it is the standard device compatible with all computers with USB ports. STM32CubeMX has all device descriptors and init procedures already built in.
Select USB device tab and set mode to “Human Interface device class”:

STM32F103 USB mouse hid
Current version of cube software is not flexible- there are no options to change more settings and select HID devices. Also it is confusing- there is no mention that it is a mouse project.
Set all other options like in previous examples, generate code and copy files from previous PS2 project. Why? We need some input and we are preparing for the next project. If you think it is complicated, just download current project files at the bottom of this post.

Continue reading

Posted in Anything, MCU | Tagged , , , | Leave a comment

ARM:0011 STM32CubeMX – Pin interrupts

Next tutorial- interrupts, keyboard (PS2 input) and USB COM port.

I have a small keyboard in my stash. It was from some flop device made by Amstrad. This keyboard has a 4 pin connector and I had hoped that it would be the USB. But after examining, I found it is PS2 only. Good stuff for the tutorial.

Amstrad PS2 keyboard
First we will do the PS2 interface and simply connect this keyboard to a virtual COM port via USB. It is possible to build a direct PS2-USB HID keyboard connection, but this is only a tutorial and we shall do it step by step.
Continue reading

Posted in Anything, MCU | Tagged , , , | Leave a comment

ARM:0009a – bug in CubeMX makefile

First you generate code, then you regenerate code, do make and…

> "make.exe" all
make.exe all -C ..
make.exe[1]: Entering directory 'F:/MyDoks/elektronika/ARM/daiktas-cube/SINGLE_UART'
Makefile:118: *** missing separator.  Stop.
make.exe[1]: Leaving directory 'F:/MyDoks/elektronika/ARM/daiktas-cube/SINGLE_UART'
make.exe: *** [makefile:3: all] Error 2

> Process Exit Code: 2
> Time Taken: 00:00

The bug is in generated main makefile:

# C includes
C_INCLUDES =  \
-IInc \
-IDrivers/STM32F1xx_HAL_Driver/Inc \
-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \
-IDrivers/CMSIS/Device/ST/STM32F1xx/Include \
-IDrivers/CMSIS/Include
-IDrivers/CMSIS/Include

 


There is a repeated line with “Include”. Just delete that line. Very interesting, but after next code generation this bug will not appear!

Posted in Anything, MCU | Tagged , , | 1 Comment

ARM:0010 STM32CubeMX- USB 2 COM dongle

This article is also an introduction, but this time a bit more practical- USB to serial port (COM) dongle. This tutorial will show how to create USB devices from “canned” software using only STM32CubeMX. For this example I used some scrap board with an STM32F102 MCU. All written in this article can be implemented in bluepill or any other STM32 chip with USB support.
I used this board because it has RS485/422 drivers on board and I was testing some concepts for my next bigger project.
STM32F102/103 USB device CDC com dongle
I have three of these boards. For testing, I closed the RS422 loop to itself. Now I have hardware echo and I can test software on heavy loads- transmission and receiving at same time.

Lets begin…
Continue reading

Posted in Anything, MCU | Tagged , , , | Leave a comment

ARM:0009 STM32CubeMX tool from STM MCUs

There will be several posts about using the cheapest MCU board from China. So called Bluepill- PCB containing STM32F103C8T6 microcontroller, USB connector and some small elements. For a few bucks/euros we have upto 72MHz CPU, 64Kb of ROM and up to 20kb of RAM. Up to 100 millions instructions on one chip.
As all ARM chips it needs quite complicated initialization code and peripheral configuration. And there are tons of peripherals on the same pin. Manufacturer of the chip, STMicroelectronics, decided to make a graphical tool for chip configuration and init libraries. Also, they included some libraries for peripherals from simple GPIO to complex USB or fat file system. And all the stuff is compatible with generic GNU C (gcc) available free from ARM holdings and other sources. Same compiler is used in the well known learning system arduino, but without the use of quasi language extension. All software can be portable to any other platform and system. ’cause it is ISO/ANSI standard!
This tool is called STM32CubeMX (stand alone tool). First versions were extremely bad and full of bugs. After several years it became usable, but still there are errors, bugs and undocumented features.

This is an intro article, tutorial about how to build your first project with lots of pictures. Sorry, this blog version is not updated to the new width of the pictures. Will be fixed soon.

STM32cubemx tutorial starting first project
Continue reading

Posted in Anything, MCU | Tagged , , | Leave a comment

Collecting horses in Fallout 4

Due to a virus outbreak I was burning my time:

horses in fallout 4
It is some type of fetish.

Posted in Anything, Personal | Tagged , | Leave a comment

Repair of the Atari 2600 jr

I found PCB from the classic 2600 JR. It was forcefully removed from the case maybe using a hammer. The PCB is bent, some parts torn out and missing switches.

Atari 2600 Jr PCB repair

PCB was cracked and several traces were broken. I repaired them, but the game didn’t start. Sometimes I noticed some video starting, but only for a few frames. I checked all connections using an oscilloscope and found that the CPU address pin (A7, maybe) is floating. I removed the chip and everything become clear:
broken UM6507 CPU
Very interesting- the chip body is broken, but the crystal is OK. Only ONE leg disconnected.

The rest of the story is very simple: ordered some cheap from China, received a fake one, opened a dispute, and received money back. Then I ordered some other and the system started up.

Posted in Anything, Vandalising | Tagged , , , | Leave a comment

Thing to know: Z80 CPU clock

I just only want to send notes to myself. Z80 CPU clock must be 5Vpp and pure TTL levels sometimes are too low for good and stable CPU work.

ancient Z80 CPU in ceramic package
Even this old CPU is very stable at 5Vpp clock, meanwhile 3.3Vpp was too low. Some CPU versions are working fine, but some are very unstable. The 3V CPLD output was good only for the CMOS version, meanwhile NMOS was not working- only 2..3 CPU cycles.
This information is not written in all available datasheets.

Posted in Anything, MCU | Tagged , , | Leave a comment

AM modulation, schematics, lots of transistors and perfect modulation

I was testing various AM radios and noticed that I don’t have a proper AM source. The AM broadcasting station in my region is very scarce and weak. Also, I wanted more options for radio receiver testing.
I thought that the internet is full of simple AM modulator circuits, but…

AM modulations some examples
Typical internet schematics are not real AM. It only “some sort” of AM modulation, and, yes, radio receivers can decode sound from these circuits. Most circuits do “1” and “2” versions, but none was like real AM.
Continue reading

Posted in Anything | Tagged , | Leave a comment

Simple Sinewave generator

There is simple and good way to generate quite pure sine wave:
simple sine wave generator
This circuit is not very simple, but results are quite fine: output is pure sine wave. From the other side, this schematics have some minuses: it is hard to change frequency. So this type of generator is not very useful for variable frequency devices.

For my purpose I am using this generator to modulate RF. Here are some oscilloscope shots of real world hardware:
Sine wave oscilloscope image

AM modulation in it’s classic way:

SIN generator

P.S. This device uses dual polarity power supply.

Posted in Anything | Tagged , | Leave a comment