台灣養殖業高密度養殖,使魚塭排泄物大增,業者常得投藥或抽地下水來換水。台大學生設計太陽能淨水裝置幫助淨化水源,水資源可重複使用,既減少汙染,還可幫助減抽地下水。
這是一個小小科學實驗室,裡面有很多很多好玩且有趣的實驗,研究內容包羅萬象,放在此處,希望有志者能一起來研究討論! ______"閱讀本blogger最佳瀏覽器 用google Chrome"_______
2011年8月31日 星期三
2011年8月30日 星期二
2011年8月19日 星期五
2011年8月18日 星期四
Porting from IAR to AVR-GCC (WinAVR)...
A few tips on porting code from IAR to AVR-GCC (WinAVR)...
1)REGISTER/MEMORY LOCATIONS have aliases in the IAR .h file, sometimes have unidentical entries in the avr-gcc files (Often, avr-gcc are the correct ones wrt the datasheet). Such entries must be edited in the source code to match avr-gcc names.
Also, .h files are not called explicitly when using WinAVR, you just use a general call, and the makefile generator takes care of calling the proper .h file.
1)REGISTER/MEMORY LOCATIONS have aliases in the IAR .h file, sometimes have unidentical entries in the avr-gcc files (Often, avr-gcc are the correct ones wrt the datasheet). Such entries must be edited in the source code to match avr-gcc names.
Also, .h files are not called explicitly when using WinAVR, you just use a general call, and the makefile generator takes care of calling the proper .h file.
2011年8月17日 星期三
avr-gcc之section與relocation
粗略的講,一個段代表一無縫隙的資料塊(位址範圍),一個段裏存儲的資料都為同一性質,如“唯讀”數據。as (彙編器)在編譯局部程式時總假設從0 位址開始,並生成目標檔。最後ld(鏈結器)在連接多個目標檔時為每一個段分配運行時(run-time)統一位址。這雖然是個簡單的解釋,卻足以說明我們為為什麼用段.
ld 將這些資料塊正確移動到它們運行時的位址。此過程非常嚴格,資料的內部順序與長度均不能發生變化.這樣的資料單元叫做段,為段分配運行時位址叫再定位,此任務根據目標檔內的參考位址將段資料調整到運行時位址。
Avr-gcc 中彙編器生成的目標檔(object-file)至少包含四個段,分別為: .text 段、.data段、 .bss 段和.eeprom 段,它們包括了程式記憶體(FLASH)代碼,內部RAM 資料,和EEPROM 記憶體內的資料。這些段的大小決定了程式記憶體(FLASH)、資料記憶體(RAM)、EEPROM 記憶體的使用量,關係如下:
程式記憶體(FLASH)使用量 = .text + .data
資料記憶體(RAM)使用量 = .data + .bss [+ .noinit] + stack [+ heap]
EEPROM 記憶體使用量 = .eeprom
2011年8月16日 星期二
typedef 不同的用法
1. typedef int (*AAA)(int R, int G, int B);
AAA pMyFunc;
這是函數指標型態的特殊定義, 也就是AAA所定義的型態為一個函數指標, 有3個int參數並傳回int值. 因此用"AAA pMyFunc;"定義後, pMyFunc便可以視為一個函數指標值, 其呼叫方法便是(*pMyFunc)(r,g,b)
2. typedef int AAA, BBB;
符號 'AAA' 與 'BBB' 皆等於 'int' , ( typedef一次只能定義一個type)
AAA pMyFunc;
這是函數指標型態的特殊定義, 也就是AAA所定義的型態為一個函數指標, 有3個int參數並傳回int值. 因此用"AAA pMyFunc;"定義後, pMyFunc便可以視為一個函數指標值, 其呼叫方法便是(*pMyFunc)(r,g,b)
2. typedef int AAA, BBB;
符號 'AAA' 與 'BBB' 皆等於 'int' , ( typedef一次只能定義一個type)
WinAVR SRAM常數與FLASH區常數的定義與讀取
定義SRAM區常量與變數的定義基本相同,在前面加上const
const uint_t s_val = 0x01;
Falsh區的整數變數的定義如下: 資料類型 變數名 PROGMEM = 值
由於FLASH的變數是不能改變的,因此最好在定義時加上const,其實FLASH區變數應叫FALSH區常量可能更合適, 我喜歡叫FLASH常數.
const uint8_t f_val PROGMEM = 0x01;
應用(讀取)方面,SRAM常量直接使用即可: 例: PORTB = s_val;
const uint_t s_val = 0x01;
Falsh區的整數變數的定義如下: 資料類型 變數名 PROGMEM = 值
由於FLASH的變數是不能改變的,因此最好在定義時加上const,其實FLASH區變數應叫FALSH區常量可能更合適, 我喜歡叫FLASH常數.
const uint8_t f_val PROGMEM = 0x01;
應用(讀取)方面,SRAM常量直接使用即可: 例: PORTB = s_val;
2011年8月14日 星期日
Porting from GCC to IAR
問題1:
Header file有說明了,為什麼說我沒有定義呢?真的鬱悶!在GCC下compile可以,為何出現identifier is undefined error?
void USART_Init(void)
{
UCSR 0C =(1<<< span>; //非同步操作,8位元資料,無奇偶校驗位,一個停止位
UBRR 0L = (F_CPU / BAUDRATE / 16 - 1) % 256;//設置串列傳輸速率
UBRR0H = (F_CPU / BAUDRATE / 16 - 1) / 256;
UCSR0B = (1<<<< span); //使能接收中斷,使能接收,使能發送
}
Error[Pe020]: identifier "UCSZ01" is undefined F:\AVR\main.c 32
Error[Pe020]: identifier "UCSZ00" is undefined F:\AVR\main.c 32
Error[Pe020]: identifier "RXCIE0" is undefined F:\AVR\main.c 36
Error[Pe020]: identifier "RXEN0" is undefined F:\AVR\main.c 36
Error[Pe020]: identifier "TXEN0" is undefined F:\AVR\main.c 36
Error[Pe020]: identifier "UDRE0" is undefined F:\AVR\main.c 44
Error[Pe020]: identifier "RXC0" is undefined F:\AVR\main.c 52
原因:
Header file有說明了,為什麼說我沒有定義呢?真的鬱悶!在GCC下compile可以,為何出現identifier is undefined error?
void USART_Init(void)
{
UCSR 0C =(1<<< span>; //非同步操作,8位元資料,無奇偶校驗位,一個停止位
UBRR 0L = (F_CPU / BAUDRATE / 16 - 1) % 256;//設置串列傳輸速率
UBRR0H = (F_CPU / BAUDRATE / 16 - 1) / 256;
UCSR0B = (1<<<< span); //使能接收中斷,使能接收,使能發送
}
Error[Pe020]: identifier "UCSZ01" is undefined F:\AVR\main.c 32
Error[Pe020]: identifier "UCSZ00" is undefined F:\AVR\main.c 32
Error[Pe020]: identifier "RXCIE0" is undefined F:\AVR\main.c 36
Error[Pe020]: identifier "RXEN0" is undefined F:\AVR\main.c 36
Error[Pe020]: identifier "TXEN0" is undefined F:\AVR\main.c 36
Error[Pe020]: identifier "UDRE0" is undefined F:\AVR\main.c 44
Error[Pe020]: identifier "RXC0" is undefined F:\AVR\main.c 52
原因:
2011年8月12日 星期五
2011年8月9日 星期二
2011年8月6日 星期六
2011年8月3日 星期三
2011年8月2日 星期二
線上轉檔工具 (Online Converter)75合1
有些時候可能因為工作需要,或某些電腦、軟體只能執行特定格式的檔案,此時我們必須把原本不支援的檔案格式轉換成其他可以支援的檔案格式,如果你不喜歡在電腦中安裝各式各樣的轉檔軟體,可以試試看本文所介紹的75合1線上轉檔工具。
打開網站之後,可以在首頁看到6種不同的工具分類,依照你要轉檔的類型不同,可以直接在下拉選單中點選你要輸出的音樂、圖片、影片、文件或電子書的檔案格式,按下「Go」按鈕之後即可執行轉檔任務。
打開網站之後,可以在首頁看到6種不同的工具分類,依照你要轉檔的類型不同,可以直接在下拉選單中點選你要輸出的音樂、圖片、影片、文件或電子書的檔案格式,按下「Go」按鈕之後即可執行轉檔任務。