Amrith’s Blog

Union magic : union in C for packing

The above code should output 0xDEAD value when run . Explanation: Union allocate the largest members size in memory , and all the members are stacked on top of each other this results in two struct fields pointing to the High byte of 16 bit union , while the other is the low byte Usage:…

Keep reading

Printf redirect to UART2 stm32

There are multiple ways to do this use they below code to override _write in printf Note: IF you do not see any output use the below code to clear buffer before calling any printf and after UART init 2. Using Putchar method: 3. third method using SWV in stm32 enable SWV before using this…

Keep reading

RiscV Workshop day 1

basic Gcc commands riscv64-unknown-elf-gcc -O1 -mabi=lp64 -march=rv64i filename.c riscv64-unknown-elf-objdump -d a.out | less simulation spike pk a.out spike -d pk a.out :until pc 0 100b0 100b0 is the memory location to jump to example main for breakpoint : reg 0 a2 // read valur of register a2

Keep reading

TMUX basics

Hierarchy in tmux: session > window > pane. Prefix for commands and help:Ctrl-b and sth: issue a command to tmux, inside tmux.Ctrl-b and ?: see all commands. Session commands:tmux: creates a new session and enters it.tmux new -s sessionname: creates a session with the specified name.tmux ls: lists all sessions.Ctrl-b and d: detach current session.Ctrl-b…

Keep reading

Emacs basics

Initial setup note: C= ctrl key , M = alt key (meta key) , example : C-x C-f means press Ctrl+x together release then press Ctrl+f together Basic commands required /info to use emacs handy commands: Cursor : Line edit : Emacs has an on-line help system that can be invoked by typing Control-H. If…

Keep reading

[2] ARM assembly

When it comes to programming Arm in thumb2 instructions there are only a handful of opcodes to be considered 1.MOV is used to copy data between registers ex: MOV R0,R1 2. Basic load/Store commands: Used to load /store data between memory and Registers MOV R2,=0x20000000 LDR R1,[R2] STR [R2],[R3] //ASSUME R3 HAS A VALID ADDRESS…

Keep reading

[1] ARM Minimal Assembly code (cortex m3/m4 + keil IDE)

ARM processors have supported two different instruction sets: the ARM instructions that are 32 bits and Thumb instructions that are 16 bits. Thumb2 instructuction was introduced later which are 32bit instruction and the processor doesnt have to switch between modes to perform instructions. ARM is faster as it requires less clock cycles for execution whereas…

Keep reading

AVR Assembly code

Simple code example for load and add instruction: AVR MCUs’ are generally fast, they can execute 16MIPS at 16Mhz because of how the busses are designed and also the simplicity of RSIC architecture. Input/ output using gpio: steps: set DDRx to 0 for input , 1 for output write PORTx value to turn on or…

Keep reading

[1] Stm32f4xx Custom PCB design using KiCAD v6

Stm32 is a widely popular MCU based on ARM core and I have always been fascinated to work with these tiny powerhouses! This post is a part of the custom PCB design build series and hopefully, I will keep posting about basic hardware design. Setup a KiCAD project as usual and we will start with…

Keep reading

[Part-1] Yocto Linux Build for Raspberry pi zero w

The Yocto Project is an open-source project that delivers a set of tools that create operating system images for embedded Linux systems. The Yocto Project tools are based on the OpenEmbedded (OE) project, which uses the BitBake build tool, to construct complete Linux images. BitBake and OE are combined to form a reference build host…

Keep reading

[6] Analog (ADC)+USART using AVR (atmega328)

I am using LDR (light dependent resistor) to get analog values Below is the explanation from datasheet regarding how to use registers to start one time conversion / free running mode. A single conversion is started by disabling the Power Reduction ADC bit, PRADC, in ”Minimizing Power Consumption” on page 51 by writing a logical…

Keep reading

[4] AVR C PWM (fast PWM, phase correct PWM )

I found this wonderful article and another one that explains the theory of PWM and the waveform and where it’s used. Since I don’t think I can improve on that I will leave it there for reference. Summary of the above article [ for lazy people like me 😉 ] : As the title suggests,…

Keep reading

[3] AVR timer 16 bit in CTC mode – timer 1 atmega328

set Timer Control register 1 (TCCR1B since WGM12 should be 1 for CTC) load the value to be compared in Overflow Compare register (OCR1A) enable interrupt for OCIE register using Timer1 Mask register (TIMSK1) enable register and set prescalar (1024 in the below example) use ISR use this online calculator for ticks calculations.

Keep reading

[2] AVR timer/ counter — CTC mode

There is a TCNTn called timer/Counter Register for each of the timers in AVR. For example, In Atmega32 we have TCNT0, TCNT1 and TCNT2.  The TCNTn is basically a counter. It counts up with each pulse. It contains zero when reset. We can read or load any value in the TCNTn register.Each of the timer…

Keep reading

Saleae Logic Analyser Clone with Ubuntu Linux

The Saleae Logic is an 8 channel 24MHz logic analyser.  Soon after its launch people in China opened them up to find that they are pretty simple inside and, as sure as night follows day, little workshops in Shenzen started producing clones impossibly cheaply and to be sold through eBay, AliExpress, etc Follow this link…

Keep reading

[1] AVR 8 bit – GPIO

For GPIO only these 3 registers are important for bit manipulation. For each port there are three important registers: x=B,C,D : example DDRB,DDRC,DDRD etc , PORTB,PORTC,PORTD etc , PINB,PINC,PIND etc. Blink.c Input using push button without any input pullup (debounce not implemented ) input pullup fo switch write 1 to the pin bit using PORTx=(1<<PIN)

Keep reading

ROS2 HUMBLE HAWKSBILL NOTES

Installation : follow the instruction: https://docs.ros.org/en/humble/Installation/Alternatives/Ubuntu-Development-Setup.html Creating a workspace: Creating a package:(Python based) ament_python should have the following dir structure setup.cfg should have: setup.py should have: __init__.py can be empty follow this link to learn more package.xml should have : CMakeLists.txt should have: build package: run the package: creating launch file: launch.py add dependency to…

Keep reading

ROS 1 notes

personal notes while learning ROS2 ROS1 installation: >Using Ubuntu as a base operating system, follow the installation guide on ROS wiki ROS1 Workspaces: >Catkin is a build system used to make workspaces, packages and libraries for ROS To create a new workspace: use this cheatsheet to refer catkin commands another interesting gist that has a…

Keep reading

Yocto Linux Qemu build basics

Using Ubuntu /Popos as a development machine Install required packages for Ubuntu/Debian-based Linux Download poky build system source from git cd into poky directory and run the init command the directory is switched to build-qemux86 (else cd into build-qemux86). Check the configuration file and set the machine to qemux86 (or qemux86-64 for 64bit) Start qemu…

Keep reading

Stm32f407vg-disc1 board -clock configuration (from scratch)

IDE used: stm32 Cube IDE official step1 > crete new project > c program and dont select stm32 project under type types of clock: HSI- high speed internal HSE- high speed external PLL- phase locked loop HSI 16MHZ setup without pll code: /** @file : main.c @author : Auto-generated by STM32CubeIDE @brief : Main program…

Keep reading

How to build Raspberry pi zero w BUILDROOT image

Lately I was reading about embedded linux and came to know about two such custom embedded linux system build sytem the Yocto project and Buildroot.I wanted to make my own custom linux for raspberyy pi zero W i had in my *ahem* attic. Requirements: Raspberry pi zero w (ofcourse) A PC (with ubuntu 18.04 or…

Keep reading

My First Blog Post

Be yourself; Everyone else is already taken. — Oscar Wilde. This is the first post on my new blog. I’m just getting this new blog going, so stay tuned for more. Subscribe below to get notified when I post new updates.

Keep reading

Note:\

Just a blog i use to write my stuff that may be useful to others too

Keep reading

Design a site like this with WordPress.com
Get started