Monday 9 October 2017

Recursive Algorithms

1. Sum of elements of array using recursion
2. Array - Linear Search 3. Array - Binary Search

Sunday 27 November 2016

ARM Cortex Hands-on Embedded Programming

I've created a course on embedded programming for ARM Cortex devices using the SAM4s Xplained Pro board from Atmel. In the following course, I will take you through 3 projects for learning how to program analog to digital converters. Use the coupon BLOGSPOT for 80% off.

https://www.udemy.com/armcortex-adc/

Monday 30 May 2016

Virtual box shared folder

I always run into a problem attaching a shared folder to my Ubuntu virtual box machine. This is what works for me.

1. Make sure you have the latest version of guest additions installed.
2. Add a shared folder using the virtual box menu and auto mount it
3. Turn on the virtual machine. Browse to /media/sf_*sharedfoldername*
4. By default with auto-mount, the shared folder will have permissions assigned to vboxsf. You need to add your current user and maybe also root to the vboxsf group so they get access to the shared folder
5. usermod -aG vboxsf <youruser>
usermod -aG vboxsf root
6. Restart virtual machine
7. Now you should have access to the shared folder under /media/sf_*sharedfoldername*

Ref: http://unix.stackexchange.com/questions/52667/file-permission-issues-with-shared-folders-under-virtual-box-ubuntu-guest-wind

Sunday 5 October 2014

Beaglebone Black using SD card as extra storage

These instructions are to use an SD card as extra storage on your beaglebone black. The beaglebone boots from internal memory and has micro SD card available for storage.

I used a Ubuntu operating system (running inside Virtual Box) to format the SD card and create the uEnv.txt file that tells the BBB not to use it as a booting device, but as external storage. My host comuputer operating system is Windows 7.

A. Format the SD card - Follow these steps


1. Insert the microSD into a USB hub on computer 

2. Mount the SD card in virtual box
3. Open Disks utility
4. Click Format and format the drive


B. Create uEnv.txt on SD card
1. Open the the volume with the file explorer and create a new file in it named uEnv.txt
2. Right Click > Create Document > Empty File
3. Open uEnv.txt and fill it with the following 4 lines of code:
mmcdev=1
bootpart=1:2
mmcroot=/dev/mmcblk1p2 ro
optargs=quiet
(Ref: http://elinux.org/Beagleboard:MicroSD_As_Extra_Storage)

C. Configure beaglebone to attach SD card on boot
1. Insert microSD in beaglebone and open ssh terminal, connect to beaglebone
2. nano to /etc/fstab file. You might need to provide chmod administrative write access for the file
3. Add the following line of code to the file
/dev/mmcblk0p1    /media/card     auto     auto,rw,async,user,nofail  0  0
(Ref: http://hifiduino.wordpress.com/2014/03/19/beaglebone-black-accessing-usd-and-usb-storage/)

D. Restart beaglebone

Thursday 4 September 2014

Setting up C cross compilation for beaglebone on ubuntu

http://wind.cs.purdue.edu/doc/crosscompile.html

Resizing Virtual Box HD

Host machine running Windows 7
VB machine running Ubuntu
Task at hand: Increase disk space of VB machine

1. Open up command prompt in host machine
Navigate to C:\Program Files\Oracle\VirtualBox

Type the following command:
VBoxManage modifyhd "C:/PATH/VB_HARD_DISK.vdi" --resize SIZE_IN_MB 

(Ref: http://askubuntu.com/questions/88647/how-do-i-increase-the-hard-disk-size-of-the-virtual-machine)

2. New hard drive space will be unallocated and has to be merged into the original hard disk. Follow instructions on this article.

-- Start from Step 3
http://derekmolloy.ie/resize-a-virtualbox-disk/

Saturday 8 March 2014

SPI and an example application - Programming ATtiny85 with Arduino as ISP.

In Non-Engineering Speak
The following post explains a communication protocol used to transfer data between two devices synchronously. Data is transferred serially, which means one bit at a time. Due to its special design, at a particular time, as a device is transmitting a particular bit, it also receives a bit from the other device.


What is SPI?

SPI is a synchronous serial transfer data protocol.

The two devices between which the data is being transferred are called the Master and Slave.
There is a full duplex connection between the two. There can only be one master at a time, but the SPI controllers can take turns being masters.

Master - Initiates connection. Provides clock source - SCK.
Slave - Receives data from Master's SPI register and sends data to Master's SPI register, forming a circular buffer.

Both Master and Slave have a 8 bit shift register. Register size can vary depending on the microcontroller, but it should be the same for both Master and Slave.

The SPI interface consists of 3 wires:
1. Serial Clock (SCK)
2. Master In - Slave Out (MISO)
3. Master Out - Slave In (MOSI)
4. (Optional) SS' - Slave select. (If more than 1 slave)

How does it work?




SPI Connections
SPI Circular Buffer Data Flow Animation


At every clock pulse, a bit is transferred from the master to the slave and a bit from the slave to the master as shown in the animation above. The microcontroller can set be set to transfer the least significant or the most significant bit first.


Application of SPI

In this example, In-Circuit Serial Programming (ISP) uses the SPI protocol to communicate between the ATMega328 microcontroller on the Arduino and the ATtiny85 microcontroller on the breadboard.

Here are some points of caution:

- When programming the AVR, the ISP always operates as the Master, and the target system always operates as the Slave.

- GND should be common.

- To stay in SPI mode, the AVR micro reset line has to be kept active (low).

- Reset has to be pulsed to end Chip Erase cycle.

- ISP should keep the entire target system reset for the duration of programming cycle.

- Target system should not attempt to drive SPI lines while reset is active.


Wiring Diagram
Picture of prototype
Follow the instructable for a step by step guide.


References
http://www.atmel.ca/Images/doc0943.pdf
http://maxembedded.com/2013/11/10/serial-peripheral-interface-spi-basics/
http://www.instructables.com/id/Program-an-ATtiny-with-Arduino/