• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: 30F2010範例可以改成30F4012嗎?
#2
版主
版主


查看用戶資訊
#include <p30f2010.h> //Standard header file
這行改以外,還有 GLD 及 MPLAB IDE 的元件選定。

其餘的你就是看看吧!還是老話 Data Sheet 要多看去了解這個元件的使用方式。你沒 try 怎會有成果?

發表於: 2008/7/21 8:57
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


30F2010範例可以改成30F4012嗎?
#1
初級會員
初級會員


查看用戶資訊
我手上有30F2010的範例:如下!
//---------------------------------------------------------------------------
// Code to flash LED and turn on LEDs when switches are pressed
//Timer1 counter 0.5s interrupt
//Switch1 exter interrupt
//---------------------------------------------------------------------------
// Header files

#include <p30f2010.h> //Standard header file

//--------------------------內部設定-----------------------------------------------
// Configuration bits

_FOSC(CSW_FSCM_OFF & XT_PLL8); //XT with 4xPLL oscillator, Failsafe clock off
_FWDT(WDT_OFF); //Watchdog timer disabled
_FBORPOR(PBOR_OFF & MCLR_EN); //Brown-out reset disabled, MCLR reset enabled
_FGS(CODE_PROT_OFF); //Code protect disabled

//---------------------------------------------------------------------------
// Definitions

#define Fcy 20000000 //7.37MHz oscillator with 4xPLL -> 7.37MIPs
#define Vi PORTBbits.RB0
#define Vo PORTBbits.RB1
#define LED1 PORTEbits.RE8 // 0.5 sec flash
#define LED2 PORTDbits.RD0 // when sw0=1 ,LED2 is on and LED3 is off
#define LED3 PORTDbits.RD1 // when sw1=1 ,LED3 is on and LED2 is off
#define SW1 PORTEbits.RE5
#define Speaker PORTEbits.RE4
//---------------------------------------------------------------------------
// Main routine
//---------------------------------------------------------------------------

int main(void)
{
//------------------------------------------------------------------------------
//Initialize LED outputs on PORTD bits 0-3 and switch inputs on PORTA bits 12 - 15

PORTD = 0xFFFF; //Turn off all LEDS
PORTB = 0xFFFF; //Turn off all LEDS
PORTE = 0x0000;
TRISD = 0xFFF0; //Set LED pins as outputs
TRISB = 0xFFFF; //Set pushbutton switch pins as inputs
TRISE = 0X0000;
//------------------------------------------------------------------------------
//Initialize Timer1 for 1/2 second period

T1CON = 0; //Turn off Timer1 by clearing control register
TMR1 = 0; //Start Timer1 at zero
PR1 = (Fcy/256)/2; //Set period register value for 1/2 second
T1CON = 0x8030; //Configure Timer1 (timer on, continue in IDLE, not gated, 1:256 prescaler, internal clock)

//------------------------------------------------------------------------------
//Loop while flashing LED RD4 and testing switch inputs

while (1)
{
if(IFS0bits.T1IF == 1) //Check if Timer1 interrupt flag is set
{
IFS0bits.T1IF = 0; //Clear Timer1 interrupt flag
LED1 = !LED1; //Toggle LED1 RD0
}
//------------------------------------------------------------------

if(SW1 == 0) //Check if SW1 button is pressed
{
LED2 = 0; //Turn LED3 RD3 on
LED3 = 1; //Turn LED2 RD2 off
}
else
{
LED2 = 1; //Turn LED3 RD3 off
LED3 = 0; //Turn LED2 RD2 on
}
}
}
//---------------------------------------------------------------------------



改成用30F4012去跑範例!
該注意哪些??除啦腳位要改!還有哪些??

發表於: 2008/7/20 16:08
剛摸PIC的電源工程師
PIC12F508
[font=Impact]剛摸PIC的電源工程師
PIC12F508
[/font]
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------