In my current project, I used Embedded C++ for MSP430 using IAR compiler. I re-created an existing assembly project and I was able to reduce the code size from 30KB down to 15KB. Yet, I have more features in my new Embedded C++ firmware. I am very careful with the C++ features that I used due to limited resources (processing power, RAM, FLASH size), the most expensive thing that I used is the virtual method which I essentially needed to implement strategy and template method design patterns. I also used the Instantiator Based Programming Paradigm to eliminate unneeded build times (similar to C++ PIMPL) and to be able to adhere to a good programming principle: "Program to Interface, Not to implementation."
At the end of the project, the code size is small, the code is very expressive, code is unit-testable and the software architecture is very flexible due to application of object-oriented design patterns.
I am very impressed with the IAR C++ compiler.
Software, Firmware, Object Oriented Software Design, Architecture, Design Patterns,3D Printing, R&D, Reverse Engineer, Electronics... This is my passion. :) I love innovation
Disclaimer: I don't post details of the projects in my professional/freelance work. Most of the projects I post here are things that I do in my free time.
Monday, 30 April 2018
Saturday, 31 March 2018
Unit Testing Simple Linux Kernel Module
This morning, I am trying to learn Linux Kernel development from https://blog.sourcerer.io/writing-a-simple-linux-kernel-module-d9dc3762c234 Link .
The examples are very good. However, I am looking for a way to do unit testing and I can't find any info on how to do this. I am a unit test advocate and I fully support unit testing. Why? Because system testing is expensive and from my experience, time-consuming.
I would like to unit test on Eclipse so that I could use Eclipse CDT and GDB's full power in terms of debugging.
With just a few #defines and #ifdefs, I was able to come up with a way to do simple unit tests using asserts. Nothing impressive actually, however the quick feedback of unit tests will be very helpful in getting good code coverage of testing.
I placed the source code demonstration here: Link
For now this will work, however I will be improving this and will be adding a proper unit testing framework.
The examples are very good. However, I am looking for a way to do unit testing and I can't find any info on how to do this. I am a unit test advocate and I fully support unit testing. Why? Because system testing is expensive and from my experience, time-consuming.
I would like to unit test on Eclipse so that I could use Eclipse CDT and GDB's full power in terms of debugging.
| Eclipse Oxygen.3 CDT Release (4.7.3) |
I placed the source code demonstration here: Link
For now this will work, however I will be improving this and will be adding a proper unit testing framework.
Thursday, 29 March 2018
My Less than $4 Faucet Temperature Monitor
This weekend, I was able to finish my temperature monitor.
I just bought the following materials:
- Temperature display with thermocouple from Ebay ($1.50)
- Crayon box from Walmart ($1)
- Electrical tape
I used my Dremel tool to fit the crayon box into my faucet. All in all, I just spent less than $4.
![]() |
| Faucet temperature monitor (I still need to tidy up the wiring LOL) |
I just bought the following materials:
- Temperature display with thermocouple from Ebay ($1.50)
- Crayon box from Walmart ($1)
- Electrical tape
I used my Dremel tool to fit the crayon box into my faucet. All in all, I just spent less than $4.
Saturday, 24 March 2018
Easy Arduino unit testing using Emulare and ArduinoUnit
I just uploaded a video on youtube on How to do Unit Testing on Arduino using Emulare and AndroidUnit. This is purely a simulator unit testing and doesn't require a board, which is great for unit testing.
Saturday, 3 March 2018
Writing NFC app using Cordova for M24LR16 I2C RFID EEPROM - but...
I am in the process of creating an Android app using Cordova with phonegap-NFC plugin. I am interfacing with an RFID I2C EEPROM M24LR16 and my firmware is already ready and tested. I have the sample Android app of ST Microelectronics and the RFID EEPROM works and I can transfer and read data. But after building the Cordova app for 1 hour, it didn't work.
Digging into the documentation, phonegap-nfc doesn't support non-NDEF tags. Most folks are suggesting to modify the phonegap-NFC library for that purpose. It is my first time to work with NFC tag firmware and this is a very good learning experience. I don't know which path to go as of the moment, but I will try to modify the phonegap-NFC library. If it doesn't work out, I will develop the Android app using Android Studio.
Update:
I had just finished creating the Android app using Java (Android Studio). It works great with Non-NDEF NFC tags. :)
Digging into the documentation, phonegap-nfc doesn't support non-NDEF tags. Most folks are suggesting to modify the phonegap-NFC library for that purpose. It is my first time to work with NFC tag firmware and this is a very good learning experience. I don't know which path to go as of the moment, but I will try to modify the phonegap-NFC library. If it doesn't work out, I will develop the Android app using Android Studio.
Update:
I had just finished creating the Android app using Java (Android Studio). It works great with Non-NDEF NFC tags. :)
Sunday, 25 February 2018
LORA: RF SX1278 Review
This weekend, I did a prototype project using LORA SX1278 for a 433MHz project. A friend of mine sent me two XL1278 module.
When I received the modules, I was so excited to test it. I have experience with TI CC1101/CC430 and NRF905 and I would like to do a comparison in terms of development time.
Upon reading the datasheet, everything is very straightforward. With the SX1278 datasheet's help, I was able to develop my C++ SX1278 driver and make it work with TI MSP430 FRAM microcontroller. Unlike, TI CC1101/CC430, I don't need any tool like SmartRF studio to get all the settings. I can just do a register computation for the frequency. Everything is straightforward with this LORA chip.
Since I don't have a spectrum analyzer, I used my $9 USB RTL-SDR (Software Defined Radio) to capture signals in the air.
![]() |
| Spektrum Interface (not an actual picture from my experiment) |
Continuing with my experiment, when there is no one transmitting, RSSI levels are at -137dBm. I tried transmitting something (I used Spreading Factor of 7 and I am transmitting 128 packets in one shot) and the receiver got a 128byte packet at -19dBm. That is pretty impressive. I haven't done my Friis equation transmission equation analysis yet but looking at this data, I believe we can achieve very far range with this one.
This is a very good module. However, I may need to try some other antenna and I may need to design a quarter wave monopole antenna by hand before doing our range test.
-Jeff
(I don't own any of the picture, please see the link)
Image from: https://www.ebay.com/itm/433-LoRa-SX1278-Long-Range-RF-Wireless-Transceivr-Module-SX1276-5Km-For-Arduino-/322929644930
https://www.rtl-sdr.com/spektrum-new-rtl-sdr-spectrum-analyzer-software/
Friday, 9 February 2018
Textwrap: Impressive python module
I am currently reverse-engineering an audio analysis algorithm which computes for the statistical variance. I needed to get around 100,000 A/D data points from the MSP430's FRAM microcontroller so that I can inject it to my unit test. With that, IAR gives me a TI-TXT format.
example:
@10000
30 20 40 50
60 70 80 90
I needed to convert this to a C array so that I can place this inside my C++ code. Here are the steps I did:
1. I extracted all the data and placed them inside a list which is very easy to do using split, appending "0x" and using join. The output will be like this:
"0x30, 0x20, 0x60" so on so forth
2. My problem with the above string is that it will take only one line of my C++ code which I feel won't look nice as I don't want to be scrolling horizontally as much as possible. I thought of creating a python algorithm to put newlines nicely without cutting a whole string like:
0x30, 0x20 ,0x
60, 0x70, 0x8
0, 0x20
Then I discovered python already covers it for me via textwrap module which I think is a smart algorithm. So now, I won't have any broken string and it will be printed nicely:
0x30, 0x20 ,0x60,
0x70, 0x80, 0x20
More information on how to use it here: https://pymotw.com/2/textwrap/
example:
@10000
30 20 40 50
60 70 80 90
I needed to convert this to a C array so that I can place this inside my C++ code. Here are the steps I did:
1. I extracted all the data and placed them inside a list which is very easy to do using split, appending "0x" and using join. The output will be like this:
"0x30, 0x20, 0x60" so on so forth
2. My problem with the above string is that it will take only one line of my C++ code which I feel won't look nice as I don't want to be scrolling horizontally as much as possible. I thought of creating a python algorithm to put newlines nicely without cutting a whole string like:
0x30, 0x20 ,0x
60, 0x70, 0x8
0, 0x20
Then I discovered python already covers it for me via textwrap module which I think is a smart algorithm. So now, I won't have any broken string and it will be printed nicely:
0x30, 0x20 ,0x60,
0x70, 0x80, 0x20
More information on how to use it here: https://pymotw.com/2/textwrap/
Subscribe to:
Posts (Atom)



