2013年5月23日 星期四

PIC32MX795F512H相關的問題PK3Err0040 error massage

這顆CHIP發現有個問題,就是燒錄問題,在programmer可以燒錄,但是轉換成Debug時候就不能燒錄,會出現這樣的Massage:


PK3Err0040: The target device is not ready for debugging.
Please check your configuration bit settings and program
the device before proceeding.


檢查之後是因為Spec上有寫到的問題

bit 3 ICESEL: In-Circuit Emulator/Debugger Communication Channel Select bit
1 = PGEC2/PGED2 pair is used
0 = PGEC1/PGED1 pair is used
bit 2 Reserved: Write ‘1’
bit 1-0 DEBUG<1:0>: Background Debugger Enable bits (forced to ‘11’ if code-protect is enabled)
11 = Debugger is disabled
10 = Debugger is enabled
01 = Reserved (same as ‘11’ setting)
00 = Reserved (same as ‘11’ setting)

原來燒錄問題是出現在這顆IC有2個燒錄方式,分別是
1. PGEC1; PGED1
2. PGEC2; PGEC2
要看當時的版子是選用哪一種方式去燒路,所以要去選擇Configure->Configuration Bit->ICESEL
要看一下線路圖,Spec預設值是PGEC2/PGED2

線路圖的話,
要看一下PIC32MX795F512,100隻腳位PGEC1/PGED1是在pin24(PGEC1),pin25(PGED1)
                                                                  PGEC2/PGED2是在pin28(PGEC2),pin27(PGED2)

2013年5月5日 星期日

AVR makefile using a library

AVR version is 4.0

如果要在Atmel的AVR建立一個Library要做以下的步驟:

1.在makefile裡面新增一行:

##Link
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)

avr-ar rcs libUART.a UART_App.o
%.hex: $(TARGET)
avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@ 

這是我擷取下來的,主要在Link後面加上 avr-ar rcs libUART.a UART_App.o   要注意一個地方,
 libUART.a 這個的lib很重要,一定要加lib不然compile不會過,avr-ar rcs libUART.a UART_App.o一定要空格

2.再到Edit Configuration Options->General->Use External Makefile 把自己寫好的makefile include進來

3.在跑一次Rebuild all,就會跑出 libUART.a

4.把自己Build的libUART.C檔移除,只剩下libUART.a

5.再到Edit Configuration Options->libraries->library search path 只到自己建立的 libUART.a路徑

6.Edit Configuration Options->libraries->Available Link Objector-> libUART.a  add Objector 到Link with These Objects->確定

7.再做一次Rebuild All