2016年3月10日 星期四

Microchip MPLAB X IDE 開發程式流程 (for beginner)


之前都用 MPLAB IDE 在開發產品,最近開始使用新版的 MPLAB X IDE。一開始問題真的好多,在一陣 try & error 後,終於比較熟悉。以下是我自己的新案子開發流程

1. 按 File -> New Project





因為在 Code Configurator 內找不到我在用的 PIC18LF2550, 所以找了一顆接腳一樣的來用。


在完成新專案後,使用 Code Configurator 來產生週邊裝置的樣版程式。我很喜歡這個功能,所以就不用舊版的 IDE。



按 Code Configurator 後,產生下面的畫面,按下 System, 設定系統頻率。





選擇所要用的週邊裝置

按 pin Manager, 選 package.





最後按下 Generate Code,




系統自動產生以下的檔案,經過小修改,然後就可以寫主要的程式。




在開發過程中,常用的功能
1. 設定 include 目錄,在專案名稱 xxx 點 2 下,





點 XC8 compiler 就可設定 include 目錄。



2. 調整字體大小。在主畫面按 TOOL -> OPTION, 在選 Fonts & Colors





2016年3月2日 星期三

How to fix ESP8266 flash issues of invalid header of packet and flash over time



Bought a ESP8266-01 and a FT232 USB2TTL boards from Ruten (Taiwan's eBay).  Both of boards were made in the China.

I use old version of esp8266_flasher.exe and the latest flash program downloaded from bbs.ai-thinker.com. I got the following error messages during upgrading process to latest firmware of V.0.9.5.2:

1. invalid header of packet.
2. flash over time

I got some solutions from google search and it seems the only way to fix this issue is to flash ESP8266 from esptool.py which we can download from Github https://github.com/themadinventor/esptool and modify the following value in the esptool.py.  Without modification, I got same error message.

    # Maximum block sized for RAM and Flash writes, respectively.
    ESP_RAM_BLOCK   = 0x1800  
    ESP_FLASH_BLOCK = 0x40     (change from 400 to 40,  I tried many times, the terminal will get error message if this value > 40) I don't know why ??? I guess it's because of the flash maker.  The one I saw on my ESP8266-01 board is Berg Micro 25Q80A I can't even find its website and datasheet.

Now, it works great under my iMac and I got the following output from new firmware:

AT

OK
AT+GMR
AT version 0.21.0.0
SDK version 0.9.5

OK

If you are the first time to use Mac OS to upgrade ESP8266 firmware, you need to install pyserial library which you can download from https://github.com/themadinventor/esptool or your Mac OS can't run the program.


在露天買了一塊 ESP8266-01 和 FT232 USB轉TTL module, 在正常工作模式下正常。但是要燒錄成最新版本時,遇到了以下問題。

問題1. 使用 esp8266 flasher 燒錄程式
燒錄時間超時

問題2.
Invalid head of packet

問題已解,解決方法在上面