Friday, September 23, 2016

Technologies and there purpose

ARM + DSP: Technology increase the DSP processing capability of  ARM. It is useful in applications like audio video codec implementation in handheld  devices, Motor control, Voice and handwriting  recognition, embedded control, FFT processing, Filtering techniques implementation for image processing.

Neon Co-Processor:  Single Instruction Multiple Data (SIMD) kinds of operation for faster results. Its application is mostly in multimedia format encoding and decoding

ARM VFP (hardware Floating Point Unit ): Provided hardware for double precision and single precision floating point arithmetics. Useful in applications like Automotive sector (ABS, Traction control etc.), 3D Graphics (Digital consument products), Imaging (Digital camera), Industrial (Motion control)

Jazelle: High performance, Low power and Low cost environment for ARM architecture. It improves multi-tasking performance of ARM. ARM Jazelle technology software is a full featured multi-tasking Java Virtual Machine (JVM), highly optimized to take advantage of Jazelle technology architecture extensions available in many ARM processor cores. Its basically makes ARM processor support Java in all better ways.

TrustZone: Technology build on system on-chip. Used for providing system wide security.

Thursday, September 22, 2016

Controlled variable memory assignment in a EMBEDDED system code: Example

Following is an example of writing embedded code, where you control the space allocation for the variable using different coding technique.

Code is executed on Keil uVision IDE: IDE-Version: µVision V5.20.0.39
Using simulator

C Compiler:      Armcc.exe V5.06 update 1 (build 61)
Assembler:       Armasm.exe V5.06 update 1 (build 61)
Linker/Locator:  ArmLink.exe V5.06 update 1 (build 61)

startup file used: startup_ARMCM4.s
CMSIS device system source file: system_ARMCM4.c
(Startup code are auto generated by Keil, during the project creation process)

-->user_main.c



int __main(void)
{


/******** Accessing IRAM memory address using pointers *******/

unsigned int *ptr_a = (unsigned int *)0x20000000;
unsigned int *ptr_b = (unsigned int *)0x20000010;
unsigned int *ptr_c = (unsigned int *)0x20000020;
unsigned int *ptr_d = (unisgned int *)0x20000030;
*ptr_a = 9;
*ptr_b = 3;
while (1)
{
*ptr_c = (*ptr_a) * (*ptr_b);
*ptr_d = *ptr_c - *ptr_a;
*ptr_c = *ptr_d - *ptr_a;
(*ptr_a)++;
(*ptr_b)++;
}



/******** Auto addressing assignment for variables in IRAM *******/
/*
static unsigned int a = 0x10;
static unsigned int b = 0x11;
static unsigned int c = 0x12;
static unsigned int d = 0x13;
a = 9;
b = 3;
while (1)
{
c = a * b;
d = c - a;
c = d - a;
a++;
b++;
}
*/


/******** Absolute addressing assignment for variables in IRAM *******/
/*
static unsigned int a __attribute__((at(0x20000000))) = 0x10;
static unsigned int b __attribute__((at(0x20000010))) = 0x11;
static unsigned int c __attribute__((at(0x20000020))) = 0x12;
static unsigned int d __attribute__((at(0x20000020))) = 0x13;
a = 9;
b = 3;
while (1)
{
c = a * b;
d = c - a;
c = d - a;
a++;
b++;
}
*/


/******** Inlining Embedded ARM cortexM4-F assembly code into C code *******/
/*
__asm
(
"MOVS r0, #0x10 \n"
"MOVS r1, #0x11 \n"
"MOVS r2, #0x12 \n"
"MOVS r3, #0x13 \n"
);
while(1)
{
__asm
(
"MUL r2, r0, r1 \n"
"SUBS r3, r2, r0 \n"
"SUBS r2, r3, r1 \n"
"ADDS r0, r0, #0x01 \n"
"ADDS r1, r1, #0x01 \n"
);
}
*/


}


Execute various segments of code one at a time to see the effect.
Run the code in debug mode.

Tuesday, September 20, 2016

7segment Display driver IC selection and connection



7 segment display are of type common:

  1. Common Anode
  2. Common Cathode
Display can be:
  1. Single Digit
  2. Multiple multiplexed digits
In these cases, the current to be driven through these segments and digits is more as compared to the current source/ sink capacity of micro-controller GPIO pins. Hence the drivers come in to picture.

Drivers are of types:
  1. HIGH side driver IC (UDN2981)
  2. LOW side driver IC (ULN2803)
Common anode configuration:
  1. It is better to go with LOW side driver, as the cathode of each segment can be connected to separate darlington pair inside driver IC to sink the current.
  2. At the anode side, single PNP(BC557) transistor can  be connected. In case of multiple digits, separate PNP transistors to be connected for each digit. 
  3. Base of each transistor will be controlled by GPIO through a series base resistor
  4. GPIOs will also be connected to driver input through a series current limiting resistor
Common cathode configuration:
  1. It is better to go with HIGH side driver, as the anode of each segment cab be connected to separate darlington pair inside driver IC to source the current.
  2. At the cathode side, single NPN (BC547) transistor can  be connected. In case of multiple digits, separate NPN transistors to be connected for each digit.
  3. Base of each transistor will be controlled by GPIO through a series base resistor
  4. GPIOs will also be connected to driver input through a series current limiting resistor

In both cases care to be taken:

  1. Care should be taken that only 1 digit is ON at a time.
  2. All n-digits can be displayed by maintaining high refresh rate of the display (eg. 180Hz)
  3. Based on Vce voltage and Isource/sink, the Power(Pd) dispation through every pin of driver can be estimated. Pd(W) * (degC/W) rating of the driver should be less than the Maximum junction temperature rating of  the driver. Otherwise driver IC is on the "Stairway to heaven" :)
More better option,
  1. There are also driver IC options like MAX7219, which have both the HIGH side and LOW side driver in the package. 
  2. MCU communicate to driver over SPI, sending digit to be displayed.
  3. Driver takes care of refresh rate (eg. 500Hz for 8 digits)
  4. Driver handles the intensity of digiti display (Layman terms  'brightness')
  5. MCU dont need to update all digits at all time, even if one digit in the number is to be modified.
Diagram where all options are merged into one:

Thursday, September 15, 2016

Important things to study

Curve fitting
- regression
- interpolation: Its is required in situation where we need to estimate peak of signal based on limited set of discrete values.
- Fourier approximation

Linear curve fitting: this kind of curve fitting introduces discontinuity in the curve
Polynomial curve fitting: removes discontinuity from the curve
Spline curve fitting:  sometimes polynomial curves make the curve fitting way too distorted by what is expected. In such scenarios spline is a better options. It behaves more like linear, but removes discontinuity from the curve.

Continuous wave Fourier transform
Discrete wave Fourier transform O(n^2)
Fast Fourier transform O(n. log2(n))

Why discrete FT required in practical applications?
--> Real life data is discrete. And DFT provided fast method of find frequency components. If Continuous FT is to be used, first interpolation is required to be done & then followed by CFT.

Why FFT is required is DFT is already there ?
--> FFT is even fast method of finding frequency content in the discrete data.

Where CFT is required practically?
--> Problems w


Significance of ROOT MEAN SQUARE: Its is derived from AC current. When AC current is passed through resistive load, the dissipate power will be same as the power dissipate when DC current of value equal to RMS of AC current is passed through same resistive load.

Mean
Variance
Standard deviation

IPC - POSIX Shared Memory

shmget() system call - create shared memory
shmat() system call - process that wish to access the shared memory  must attach it to their address space
shmdt() system call - when process no longer wish to access the shared memory, it can be detached from the address space using this call
shmctl() system  call - remove shared memory from system

Other processes that wish to access this shared memory must first attach to it using shmat()

---------------------------------------------------------------------------------------------
IPC_sharedmemory.c
---------------------------------------------------------------------------------------------


Wednesday, September 14, 2016

JTAG, SWD and debugWIRE: How are they different ? Its always a question ..... Let me clarify

JTAG - Joint Test Application Group
- Its used for verifying design and testing PCB after manufacturing
- Its referred as IEEE Standard 1149.1
- Standard Test Access Port and Boundary-Scan Architecture
- Programming and debugging both can be done using JTAG

Physical interface:

  1. TDI (Tets Data In)
  2. TDO (Test Data Out)
  3. TCK (Tets Clock)
  4. TMS (Test Mode Select)
  5. TRST (Test Reset)
Daisy chain way of using JTAG

Example of JTAG chain


SWD - Serial Wire Debug

Serial Wire Debug (SWD) is debug port for microcontroller where package is small, or small number of pins.
Its used mostly in ARM architecture chips
SWD is availabel as a part of Core Sight Debug access port
Compatible with all ARM processors, and any processor that uses JTAG
- Programming and debugging both can be done using SWD
Physical interface: 
  1. SWCLK (Serial Wire Clock)
  2. SWDIO (Serial Wire Data In and Out)
In case when SWD is used for JTAG based process
  1. SWCLK --> TCK
  2. SWDIO --> TMS
With SWD protocol, the debugger is connected to AMBA bus as another master, using which debugger can access ARM core system and peripheral memory

NOTE:
Ofcourse, VCC and GND need to be common between In-Circuit-Debugger/Programmer and Processor

SWO (Serial wire out) wire is used sometimes along with SWCLK and SWDIO.
Some of the programmer and debuggers like STLINK provide debugging utility like printf(), which are very useful. These utilities use SWO wire to send serial data over it to PC. But here you need to set the system clock value correctly in the serial debug viewer configuration on PC.

debugWIRE

debug WIRE is a single wire interface provide in most Atmel AVR microcontrollers.
Its even more beneficial compared to JTAG and SWD as its very useful in places where package pin count is very small. On-Chip-Debugger (OCD) is provided on silicon itself by Atmel. dW single wire is internally connected to OCD. Whenever BREAK instruction (Software breakpooint) or (Hardware breakpoint) is observed by OCD, the CPU core operation is stopped and halted. All the SRAM, Peripheral register values, IO status information is sent by OCD over dW wire to the External Debugger unit(JTAGICE3). It will convert dW information to USB so that information could be sent to PC. On PC there will be a Debug software program which will grab the data and display it. Debug software running on PC will be a part of AtmelStudio.
- Only debugging both can be done using debugWIRE
- SPI interface is used for programming where dW debug interface is used



Physical interface:
Single wire dW.
Its a alternate functionality for RESET pin of the micro controller.

Microcontroller oscillator circuit working

 Circuit consists of two parts: an inverting amplifier that supplies a voltage gain and 180° phase shift and a frequency selective feedback path. The crystal combined with Cx and Cy form a tuned PI network that tends to stabilize the frequency and supply 180° phase shift feedback path. In steady state, this circuit has an overall loop gain equal to one and an overall phase shift that is an integer multiple of 360°. Upon being energized, the loop gain must be greater than one while the voltage at XTAL grows over multiple cycles. The voltage increases until the NAND gate amplifier saturates. At first glance, the thought of using a digital NAND gate as an analog amplifier is not logical, but this is how an oscillator circuit functions.


Friday, September 2, 2016

Important specs while selecting MCU


  1. Memory architecture: Von-neumann or Harvard or Modified Harvard
  2. Instruction set architecture: RISC or CISC
  3. Operating frequency
  4. CPU operating modes
  5. Coremark benchmarking results of MCU. Or results like matrix multiplication/inverse calculation, FFT etc. related benchmarking is good to judge MCU.
  6. Application category based selection: Ultra low power, Mainstream, High performance (as in case of ST)
  7. Peripheral available on MCU
  8. Number of Timers: Basic, Genereal purpose and High resoluation
  9. Number of external interrupt lines.
  10. Number of internal interrupt lines.
  11. DMA necessary when large data transfers are important in application.
  12. CRC and MPU (memory protection unit):
    1. CRC is used while compiling teh binary and writing data to Flash. Its is then decoded using the same CRC to verify the read instruction is correct, inside CPU
    2. MPU is used mostly in RTOS level applications, where we need isolation between kernel area and user domain. This protects the kernel memory area from user code intervention
  13. FPU (Floating point unit): Its is necessary when there are many floating point multiplications and divisions in the code. This makes the code execution very fast, as compared to the software FPU implemetation (aebi_vfpu())
  14. ADC: High sampling rate, Effective number of bits (ENOB), Resolution. Also look for internal temperature compensation availability as it helps if compensation of temperature drifts in the application. 
  15. Communication peripherals: I2C, SPI, UART
  16. Analog peripheral on chip: programmable gain OPAMP, Analog COMPARATORs. These are necessary for applications where they play role in reducing cost of products, by decreasing cost of external components required.
  17. Power consumption in various modes. This is particulary important when you are dealing with portable device applications like electronic handheld device, smart watch etc.

PROFILE

My photo
India
Design Engineer ( IFM Engineering Private Limited )

Followers