- Debug mode is slow, for example, LDH (load) will follow by a NOP4 (no operation), no pipeline.
- Call function needs 6 cycles, return needs 6 cycles.
- Level of optimization: -o1(local, single block), -o2(function, across blocks), -o3(file, across functions), -pm -o3(program, across files)
- uint32_t is good and the same in different system. 'long', 'int' will be different in different system.
- Keyword 'restrict': tell the compiler that in this scope, no aliasing for this pointer. (aliasing: e.g. one memory location, two ways to access it)
- It is not good to insert "asm(...)" in C codes. If necessary, try to create an asm file and call it in C.
- The results of different optimization methods: Debug, no opt, -g (925k cycles), Release -o2, no -g (33k c), opt (20k), opt with MUST_ITERATE (17k), opt with MUST_ITERATE and restrict (7k), DSPLib (8k)
- Cache has Valid + Tag + Index. Data is cache is reusable, it is good for temporal locality and spatial locality, not good for random number.
- y = \sum a_n x_n, the address of a is 8000 and x is 8010. Trouble here because the last digits are '0', it is the same index.
- Use Direct-Mapped Cache (1-way), associates an address within each block with one cache line, there will be only one unique cache index for any address in the memory-map. Good for L1P (level 1 program). 2-way set associate is good for L1D
Sunday, February 03, 2013
TI C6000 SYS/BIOS (3)
Friday, February 01, 2013
Compare RTOS and GPOS
General Purpose OS vs. Real-time OS
The main purpose and benefit of using RTOS is to easily configure and execute common tasks in the system.
Typically causes an interrupt from a peripheral are: need of service (data ready), status flag(RRDY)
The main purpose and benefit of using RTOS is to easily configure and execute common tasks in the system.
Typically causes an interrupt from a peripheral are: need of service (data ready), status flag(RRDY)
TMS320C674x Architecture
Level 1 Data (L1D) cache, small and fast inside 1 cycle
Level 1 Program (L1P) cache
L2 cache is about 2 cycle
Through SCR (switched central resource) will slow down
L3 is shared memory between ARM and DSP, about 6-8 cycles
DDR2 is about 10 cycles
Wednesday, January 30, 2013
TI C6000 SYS/BIOS (2)
- Pulling is kind of like keep asking "ready? ready? ready?"
- Interrupt is like domino, trigger one thing, then another, the goal is to tell CPU
- C64+ interrupt:
- Interrupt source: EDMA, timer, hardware pin, total 128 bytes, includes 124 unique and 4 combined
- Interrupt selector: 128 (124+4) INT source go through mask to trigger 12 (16-4) INT, where the 4 is (0-reset, 1-NMI, 2,3- Emu0,1)
- Set flag in interrupt Flag Register (IFR)
- check Individual Enable Interrupt (IER)
- check Global Interrupt Enable (GIE)
- Auto hardware sequence, IFR=0, PC->stack, Branch to ISR
- IRS: context save, process, context restore, return Interrupt
- 4 steps programming: interrupt selector, IER(enable it if you want to 'listen to'), GIE (enable it), context save/restore.
- HWI: fast response to INTs, minimum context switching, high priority to CPU, limited number of HWI. HWI prioritys set by hardware with fixed number
- SWI: latency in response time, context switch, selectable priority levels, scheduler manages execution
- SYS/BIOS provides for HWI and SWI management, allows HWI to post a SWI to the ready queue
- SWI priority from 1-32, low to high. If a higher priority thread becomes ready, the running thread is preempted. If same priority, then FIFO
- swi_post(mySwi): unconditionally post a software interrup
- In SYS/BIOS, swi needs 280 cycles, task need 320 cycles.
- Task has up to 32 priority levels, any number possible. All tasks are preempted by all SWI and HWI
- All SWI are preempted by all HWI
- Preemption among HWI is determined by user
- In absence of HWI, SWI, and Task, Idle functions run in loop
- Task codes: prolog, while(1), semaphone_pend(), process, Epilog.
- Set up hardware timer need to define: tick rate (uS), clock module programs timer and ISR
- Semaphore_pend() only waits on one flag - a semaphone, what if you want to unblock based on multiple events? Use Events. It can OR or AND event IDs with bit masks
- Queue is a BIOS object that can contain anything you like, it is NOT copy based, use queue_put(), queue_get(). No signalling built in (cannot black)
- Sync Queue using "talker and Listerner" mode. Talker: Queue_put(&myQ, msg); semaphone_post(&sem). Listerner: semaphore_pend(&sem, -1), msg=Queue_get(&myQ);
- Mailbox is a fixed size BIOS object. Use Mailbox_post(...), Mailbox_pend(...). It is FIFO, contains built-in semaphore for signalling, it is copy-based so that you want to use a pointer, or small size data
- MUTUX can cause priority inversion and deadlock
- Two basic data sharing models are "producer-consumer" (queue, mailbox, semephore/event), "concurrent access" (mutex, same priority, scheduler management)
- Threads at the same priority cannot pre-empt each other, it is a good idea to place threads that share a critical resource at the same priority. It has built-in FIFO scheduling, no signaling required (no semaphore, no blocking), very simple to solve critical resource sharing problems(e.g. priority inversion and deadlock)
Tuesday, January 29, 2013
TI C6000 SYS/BIOS (1)
- 66x - shannon with 8 cores
- DM816x - Netra
- The key different between Embedded and others: memory design, usage and management.
- About 10000 cycles if using "printf" on DSP, about 10 cycles if using internal logprint
- SYS/BIOS is called BIOS6.x, it runs on all TI devices, has ARM m3, m4, A8, msp430
- SYS/BIOS is scalable, real-time kernel, the configuration includes: memory management, real-time analysis, scheduling (thread), synchronization (semaphore...)
- L1 cache, small and fast in about one cycle, L2 cache with about 2 cycle, share memory between ARM and DSP is about 6-8 cycles, DDR is about 10 cycles
- Emulator: XDS100 v1, v2, 1mHz with free CCS, Spectral Digital XDS510 10mHz for $1000, Blackhawk XDS 560v2 30-40mHz for $1500.
- Integer is 32 bits in C6000, short is 16 bits
- Scheduler is the most important part of BIOS
- Pre-emptive: highest priority always wins
- the word "thread": functions running with priorities within a specific context (stack)
- Switch tasks need 500 cycles, swith SWI need 200 cycles
Thursday, December 27, 2012
New OpenCV book: Mastering OpenCV with Practical Computer Vision Projects
Packt has recently published its first book on OpenCV titled “Mastering OpenCV with Practical Computer Vision Projects”. Written by Daniel LĂ©lis Baggio. This book contains examples with source codes
This is a good addition to OpenCV cook book. The book covers different ways you could use you OpenCV skills in developing real computer vision applications. Most projects in the book are very useful and traditional computer vision problems. The most interesting chapters for me is chapter 1 and 5. Chapter 1 shows how to use OpenCV on android platform. Chapter 5 shows the car license plate recognition application with SVM.
Mastering OpenCV with Practical Computer Vision Projects
This is a good addition to OpenCV cook book. The book covers different ways you could use you OpenCV skills in developing real computer vision applications. Most projects in the book are very useful and traditional computer vision problems. The most interesting chapters for me is chapter 1 and 5. Chapter 1 shows how to use OpenCV on android platform. Chapter 5 shows the car license plate recognition application with SVM.
Mastering OpenCV with Practical Computer Vision Projects
Thursday, December 20, 2012
Delete images in Android
We want to delete all images in a specific directory(FILE_OUT_DIR), here is the function:
In the program, you call:
This won't work because Android cache the media files. The files are still in the directory. We have to add:
And in AndroidManifest.xml, add:
Wednesday, December 05, 2012
Hough transform from wiki
from wiki:
- For each data point, a number of lines are plotted going through it, all at different angles. These are shown here as solid lines.
- For each solid line a line is plotted which is perpendicular to it and which intersects the origin. These are shown as dashed lines.
- The length (i.e. perpendicular distance to the origin) and angle of each dashed line is measured. In the diagram above, the results are shown in tables.
- This is repeated for each data point.
- A graph of the line lengths for each angle, known as a Hough space graph, is then created.
Thursday, November 29, 2012
"Project Explorer" disappeared in Eclipse
Cannot find it without a search. It's located at:
Window > Show View > Other... > General > Project Explorer.
Display line number in eclipse editor:
“Windows” > “Preference” > “General” > “Editors” > “Text Editors” , check on the “Show line numbers” option.
Window > Show View > Other... > General > Project Explorer.
Display line number in eclipse editor:
“Windows” > “Preference” > “General” > “Editors” > “Text Editors” , check on the “Show line numbers” option.
Wednesday, November 28, 2012
Matlab: map an image with lookup table
Suppose we have a lookup table (lut.txt) look like (two columns):
0 0
1 0.0005
2 0.0006
3 0.002
.
.
254 0.981
255 1
Only save the 2nd column to LUT0.txt:
0
0.0005
.
.
0.981
1
matlab code:
load LUT0.txt;
img_gamma = LUT0(im2uint8(InputImage)+1);
0 0
1 0.0005
2 0.0006
3 0.002
.
.
254 0.981
255 1
Only save the 2nd column to LUT0.txt:
0
0.0005
.
.
0.981
1
matlab code:
load LUT0.txt;
img_gamma = LUT0(im2uint8(InputImage)+1);
Subscribe to:
Posts (Atom)




