Showing posts with label PIC. Show all posts
Showing posts with label PIC. Show all posts

Wednesday, July 18, 2018

對MPLAB X IDE產生之專案導入git

MPLAB X IDE產生之專案架構

MPLAB X IDE產生之專案會XXX.x以.x做結尾。常見的檔案樹如下:
.
├── build
│   └── default
│       └── production
│           ├── main.o
│           └── main.o.d
├── debug
│   └── default
├── dist
│   └── default
│       └── production
│           ├── 4013_test.X.production.elf
│           ├── 4013_test.X.production.hex
│           └── 4013_test.X.production.map
├── main.c
├── Makefile
└── nbproject
    ├── configurations.xml
    ├── Makefile-default.mk
    ├── Makefile-genesis.properties
    ├── Makefile-impl.mk
    ├── Makefile-local-default.mk
    ├── Makefile-variables.mk
    ├── Package-default.bash
    ├── private
    │   ├── configurations.xml
    │   └── private.xml
    └── project.xml
可以發現build/default、debug/default、dist/default/底下存有編譯時期產生之檔案,而nbproject/private則存有當前專案於當前系統中實際之相依toolchain路徑。

Git Ignore

有了前面的事實,我們git ignore應該寫成如下:
*/nbproject/private/
*/dist/default
*/build/default
*/debug/default

至少需拔掉編譯時期會產生檔案。此外nbproject下的Makefile相依檔案,如Makefile*, XXX.mk等一定要進入git。

跨OS issue

雖然MPLAB X IDE產生的專案可以輕易在LINUX上與Windows上運行,不過為了紀錄OS資訊,MPLAB X IDE會在Makefile-genesis.properties這些properties檔案中存入作業系統資訊。因此git在這些區域容易出現問題(confilct)。比較好的辦法就是不要跨平台。然而若是仍須跨平台,Makefile-genesis.properties5這檔案可能會造成MPLAB X IDE找不到compiler或是toolchain。因此可以透過MPLAB X IDE  GUI界面,選擇project properties,重新創立properties。

NetBeans git plugin

MPLAB X IDE是以NetBeans為基礎,所以也可以使用NetBeans的git plugin。

Saturday, April 29, 2017

I2C 使用Microchip plib

I2C 使用Microchip plib

本篇以dsPIC30F為主。

plib 安裝

Legacy PIC24 MCU & dsPIC DSC Peripheral Library下載最新的plib,然後她會要求將plib安裝到你電腦中xc16 complier的資料夾下(linux在”/opt/microchip/xc16”下)。

函式概覽

安裝後文件會在xc16 complier的docs/periph_libs下。
其中plib提供以下函式。
AckI2C
CloseI2C
ConfigIntI2C
DataRdyI2C
IdleI2C
MastergetsI2C
MasterputsI2C
MasterReadI2C
MasterWriteI2C
NotAckI2C
OpenI2C
RestartI2C
SlavegetsI2C
SlaveputsI2C
SlaveReadI2C
SlaveWriteI2C
StartI2C
StopI2C
還有一些MARCO
EnableIntMI2C
DiableIntMI2C
SetPriorityIntMI2C
EnableIntSI2C
DisableIntSI2C
SetPriorityIntSI2C
這份文件16 bit language tools第191頁開始有詳述這些函式的介面。所以本文主要會面向如何運用這些函式達成master與slave溝通。

I2C (dsPIC30F as Master with 7bit address)

reception

以下圖片來自於http://ww1.microchip.com/downloads/en/DeviceDoc/70046E.pdf

對應到plib的流程為。(以下為我在i2cdevlib中所新增的片段,為一次讀多個bytes)。

請先透過ConfigIntI2C和OpenI2C設定好硬體參數。
值得注意的是在dsPIC30F manual中第5步驟。要透過StartI2C再次產生start condition。而讀入多個data bytes可用MastergetsI2C函式。

transmission

transmission只要全部都由Master端給資料即可。
對應到plib的流程為。(以下為我在i2cdevlib中所新增的片段,為一次寫多個bytes)。
請先透過ConfigIntI2C和OpenI2C設定好硬體參數。

Written with StackEdit.

精選文章

使用Ardunio Atmega2560 連接 nRF24L01+

使用Ardunio Atmega2560 連接 nRF24L01+ 關於library 目前主流有 https://github.com/maniacbug/RF24 與 https://github.com/TMRh20/RF24 這兩個。 其中TMRh20大大做...