|
|||||||||||
| 技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng) 驅(qū)動編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機 | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計 | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe |
關(guān)于pic18f6520的C編程求助! |
| 作者:sky115 欄目:單片機 |
剛接到一個項目,經(jīng)前期調(diào)研、方案確立及可行性分析之后,擬采用18PICF6520,在網(wǎng)上下載了一個支持pic18f××20的編譯環(huán)境,也在里面調(diào)試過一個用匯編編寫的程序,感覺還不錯。 我希望能用C語言。以前寫過51系列的,對PIC的C程序,還只能算是一個新手,所以,不知該從何下手,還望各位大蝦多提建議、多多幫助,先行謝過了! 尤其渴望哪位朋友能提供一個關(guān)于PIC18F××20系統(tǒng)的用C語方寫的應(yīng)用程序例子,不勝感激! 謝謝支持:give_panyong@163.com |
| 2樓: | >>參與討論 |
| 作者: 張明峰 于 2003/5/7 15:41:00 發(fā)布:
用的是什么C編譯器? 我用MICROCHIP的MPLAB C-18和Hitech的 PICC-18 |
|
| 3樓: | >>參與討論 |
| 作者: sky115 于 2003/5/7 16:27:00 發(fā)布:
代理商推薦了一個IDE 6.20 我一直在網(wǎng)上找有關(guān)PIC18F**20系列的C程序模板,毫無所獲。 請問你有嗎? 另外:我剛下了一個c18,還沒正式用; picc好像不支持PIC18F**20系列吧? |
|
| 4樓: | >>參與討論 |
| 作者: 張明峰 于 2003/5/7 17:16:00 發(fā)布:
范例 #include <p18f6620.h> void isr_high(void); void isr_low(void); //************************************************ //* #pragma Interrupt Declarations * //************************************************ //************************************************ //* Function: isr_high_direct * //* - Direct execution to the actual * //* high-priority interrupt code. * //************************************************ #pragma code isrhighcode = 0x0000008 void isr_high_direct(void) { _asm //begin in-line assembly goto isr_high //go to isr_high function _endasm //end in-line assembly } //************************************************ //* Function: isr_low_direct * //* - Direct execution to the actual * //* low-priority interrupt code. * //************************************************ #pragma code isrlowcode = 0x0000018 void isr_low_direct(void) { _asm //begin in-line assembly goto isr_low //go to isr_high function _endasm //end in-line assembly } #pragma code //************************************************ //* Function: isr_high(void) * //************************************************ void isr_high(void) { //***high priority interrupt CODE HERE*** } //************************************************ //* Function: isr_low(void) * //************************************************ void isr_low(void) { //***low priority interrupt CODE HERE*** } void main(void) { while (1) { } } 請仔細(xì)閱讀MPLAB C-18的使用手冊,重點理解#pragma的用法。接下來你將碰到的很多問題都和#pragma的使用相關(guān)。祝好運! |
|
| 5樓: | >>參與討論 |
| 作者: sky115 于 2003/5/8 8:49:00 發(fā)布:
非常感謝! To 張明峰: 非常感謝您的幫助,有機會時,小酌幾杯如何? |
|
| 6樓: | >>參與討論 |
| 作者: 張明峰 于 2003/5/8 9:01:00 發(fā)布:
沒問題 可以喝一點。先謝了。 |
|
| 7樓: | >>參與討論 |
| 作者: sky115 于 2003/5/8 10:09:00 發(fā)布:
PIC18C系列和PIC18F系列指令是否是兼容的? PIC18C系列和PIC18F系列指令是否是兼容的呢,它們的區(qū)別是否只在于F是閃存,而C卻是OTP? |
|
| 8樓: | >>參與討論 |
| 作者: sky115 于 2003/5/8 10:33:00 發(fā)布:
還有,還有! 小弟快暈了,能不能再幫我提供一個匯編的模板程序?謝謝,謝謝!:( |
|
| 9樓: | >>參與討論 |
| 作者: 張明峰 于 2003/5/8 11:55:00 發(fā)布:
匯編程序的模板MPLAB自己有 在其安裝目錄下:如 C:\Program Files\MPLAB IDE\MCHIP_Tools\TEMPLATE\Object |
|
| 10樓: | >>參與討論 |
| 作者: sky115 于 2003/5/8 17:36:00 發(fā)布:
匯編程序模板 TO 張明峰: ;****************************************************************************** ; This file is a basic template for creating relocatable assembly code for * ; a PIC18F6520. Copy this file into your project directory and modify or * ; add to it as needed. Create a project with MPLINK as the language tool * ; for the hex file. Add this file and the 18F6520.LKR file to the project. * ; * ; The PIC18FXXX architecture allows two interrupt configurations. This * ; template code is written for priority interrupt levels and the IPEN bit * ; in the RCON register must be set to enable priority levels. If IPEN is * ; left in its default zero state, ONLY the interrupt vector at 0x008 will * ; be used and the WREG_TEMP, BSR_TEMP and STATUS_TEMP variables will not * ; be needed. * ; * ; REFER to the MPASM User's Guide for additional information on the * ; features of the assembler and linker. * ; * ; REFER to the PIC18FXX20 Data Sheet for additional information on the * ; architecture and instruction set. * ; * ;****************************************************************************** ; * ; Filename: * ; Date: * ; File Version: * ; * ; Author: * ; Company: * ; * ;****************************************************************************** |
|
|
|
| 免費注冊為維庫電子開發(fā)網(wǎng)會員,參與電子工程師社區(qū)討論,點此進(jìn)入 |
Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號 |