Sunday, October 12, 2008

AD converter: TI ADS1110

AD reference voltage不需由外部提供. 2.048V
Analog input voltage: ±2.048V (V+in - V-in) ( -2.048 ~ +2.048V )
目前的使用方式, V-in直接接地, analog input voltage的範圍: 0 ~ +2.048V
精確度由16-bits降為15-bits.



Sunday, August 3, 2008

Mutex


Priority arrangement
HH: RS485 Rx handler
H: Voltage control
M: Peripheral
L: SMR


void
COMM_Init()
{
Create mutex for RS485 driver.
Create a task, named RS485 Rx Handler.
}


bool
RS485_TxHandler(byte *pPacket, bool waitSlave, portTypeTick delay )
{
if ( mutex is not available )
{
delay;
if ( mutex is still not available ) return false;
}

if ( waitSlave ) resume task, RS485 Rx Handler.
......
.....
other codes.
....

release the mutex.
}


void
Task_RS485_RxHandler
()
{
byte c;
Suspend itselt;

for(;;)
{
Delay 5ms.
while( RS485_GetByte( &c, delay_2ms ) )
{
if ( Get a legal RS485 Packet ) {
Signal semaphore, SEM_RS485_Arrive_Packet;
break;
}
}
Suspend itself.
}
}


Binary Semaphore : 用於Task之間的同步
Mutex : (MUTual EXclusion semaphores), are used by tasks to gain exclusive access to resources. A mutex is used by App to reduce the priority inversion problem.

Thursday, June 19, 2008

ColdFire 5208EVBe

uClinux has builed in.

Console connection:
Baudrate: 115200bps
Port: Terminal UART0

Saturday, May 10, 2008

資料連結層

通訊協定構成的大部分是在七層模型中的資料連結層內,資料連結層分割成兩個不同的階層:
1. Logical link control layer
2. Media access control layer
Logical link control layer是在資料連結層的軟體或韌體側。
Media access control layer是控制器內的硬體層或電腦內的介面卡,用於存取實質媒體。

Reference: 嵌入式微控制器設計與故障檢修實務, 6.3.3

Thursday, March 27, 2008

邊界不對齊資料和位元組排列方式

ARM 的 Load 和 Store 指令假設位址是正在下載或者儲存的資料類型長度的數倍, 如果下載和儲存的位址與資料類型邊界不對齊,可能會產生異常的結果,例如資料異常或者下載了一個旋轉位元的值。對於良好撰寫、可移植的程式碼,應該儘量避免使用邊界不對齊的存取。

C 編譯器通常情況下假設指標是邊界對齊的。

Sunday, March 9, 2008

Memory management issue - FreeRTOS

FreeRTOS-A Free RTOS for ARM7, ARM9, Cortex-M3, MSP430, MicroBlaze, AVR, x86, PIC32, PIC24, dsPIC, H8S, HCS12 and 8051

Scheme 2 - heap_2.c

This scheme uses a best fit algorithm and, unlike scheme 1, allows previously allocated blocks to be freed. It does not however combine adjacent free blocks into a single large block.


-----------------------------------------------------------------------------------
Note:
上文提到, 該Memeory management無法自行結合許多小塊的Free memory fragment, 但不知道memory fragment會不會隨呼叫malloc的次數而增加?

Bug:
呼叫malloc多次 (產生多個小塊的Free memory fragment), 且每一次呼叫allocate的memory size都必須比前一次allocate的size還大, 目的是為了產生許多的memory fragment. malloc在呼叫的過程中會先尋找目前free memory fragment list中free memory size是否有符合目前需要的, 如果沒有才會在剩餘的heap空間中產生一個fragment並加到memory list中.
malloc
allocate memory失敗的原因: 在free memory fragment list中沒有符合需求的block同時剩餘的heap size也不足時便會回傳作業失敗。所以如果malloc本身有能力將free fragment list中小block重組成較大的block便可克服.


Pseudo code
u32 size;
while(++size &&
malloc(size));

Thursday, January 10, 2008

Ymodem First Packet

第一個Ymodem封包大小為128bytes, 資料內容(橘色)為:檔案名稱, 檔案大小. 其餘未使用的資料值填入0.

00 0100FF62 62637363 6865642E 74787400 |...bbcsched.txt.|
10 36333437 20333331 34373432 35313320 |6347 3314742513 |
20 31303036 34340000 00000000 00000000 |100644..........|
30 00000000 00000000 00000000 00000000
40 00000000 00000000 00000000 00000000
50 00000000 00000000 00000000 00000000
60 00000000 00000000 00000000 00000000
70 00000000 00000000 00000000 00000000
80 000000CA 56