在使用PIC18系列是常使用的就是c18的compiler,

我們要使用的函數, 如PWM可以自己寫, 或是call c18已經寫好的函數如OpenPWM(), ClosePWM()

我們可以進一步去看裡面的程式碼, 會發現會有EPWM_V14或EPWM_V14_1的版本定義, 如下面的程式碼:

#elif defined (EPWM_V14) || defined (EPWM_V14_1)
void OpenEPWM1( unsigned char period, unsigned char timer_source )
{

  ECCP1CON=0b00001100;   //ccpxm3:ccpxm0 11xx=pwm mode

  //configure timer source for CCP
  CCPTMRS0 &= 0b11111000;
  CCPTMRS0 |= ((timer_source&0b01110000)>>4);  
 
  if( (CCPTMRS0&0x07)==0x00)
  {
  T2CONbits.TMR2ON = 0;  // STOP TIMERx registers to POR state
  PR2 = period;          // Set period
  T2CONbits.TMR2ON = 1;  // Turn on PWMx
  }

想要到我們所使用的MCU是屬於哪一種定義的嗎?

答案就要到C18資料夾中的h資料夾,

裡面有一個pconfig.h

比如說使用的是pic18f45k20, 裡面就有一段定義:

#ifdef   __18F45K20
/*############################################################*/
/*          Configuration for device =  'PIC18F45K20'         */
/*############################################################*/

/* ADC */
#define ADC_V8

/* ECC */
/*No configuration chosen for this peripheral*/

/* CC */
#define CC_V2

/* EPWM */
#define PWM_V11

/* PWM */
#define PWM_V10

/* PCPWM */
/*No configuration chosen for this peripheral*/

/* USART */
#define EAUSART_V5

/* SPI */
#define SPI_V1

/* I2C */
#define I2C_V1

/* TIMERS */
#define TMR_V2

/* EEPROM */
#define EEP_V2

/* PORT_B */
#define PTB_V1

/* ANCOMP */
#define ANCOM_V5

/* MWIRE */
#define MWIRE_V1

/* CTMU */
/*No configuration chosen for this peripheral*/

/* PPS */
/*No configuration chosen for this peripheral*/

/* RTCC */
/*No configuration chosen for this peripheral*/

/* DPSLP */
/*No configuration chosen for this peripheral*/

/* PMP */
/*No configuration chosen for this peripheral*/

/* FLASH */
#define FLASH_V1_2

#endif

 

這樣就可以找到MCU所使用的C18函數版本定義了 ^^

 

arrow
arrow
    文章標籤
    pic18f45k20 pwm c18 compiler
    全站熱搜

    fishark 發表在 痞客邦 留言(0) 人氣()