コード例 #1
0
// *****************************************************************************
// *****************************************************************************
// Section: System Interrupt Vector Functions
// *****************************************************************************
// *****************************************************************************
void __ISR(_CHANGE_NOTICE_VECTOR, ipl4AUTO) _IntHandlerChangeNotification(void)
{

    /* TODO: Add code to process interrupt here */
    PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_CHANGE_NOTICE_A);
    PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_CHANGE_NOTICE_B);
    PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_CHANGE_NOTICE_C);

}
コード例 #2
0
ファイル: system_int.c プロジェクト: ctapang/v0_70_01b
ChangeNoticeHandler(void)
{  
    /* If the button was not already pushed down, process interrupt */
    if (!buttonWasPressed)
    {
        buttonWasPressed = true;

       /* Blocking delay causing the WDT to fail to be serviced in time */
        int i;
        i = 1024 * 100;
        while (i--);
    }

    /* If the button was already pushed down, ignore the interrupt */
    else
        buttonWasPressed = false;


    unsigned int temp;

    /* Read port to clear mismatch on change notice pins */
    temp = PLIB_PORTS_Read(PORTS_ID_0, PORT_CHANNEL_D);

    /* Clear the interrupt flag */
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_CHANGE_NOTICE);
}
コード例 #3
0
void IntHandlerDrvTmrInstance0(void)

{

    PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_TIMER_2);

}
コード例 #4
0
void IntHandlerDrvUsartInstance0(void)
{
    /* TODO: Add code to process interrupt here */
    //if (!DRV_USART0_ReceiverBufferIsEmpty()){
                //stopAll();
        char incomingByte = DRV_USART0_ReadByte();
        receiveSendValFromISR(&incomingByte);      
   // }
 
    // If transmitter not enabled, interrupt never occurs here (messages still go through over wifly)
    // Transmitter enable -> Empty Flag up      
    if (PLIB_USART_TransmitterIsEmpty(USART_ID_1)) {
        receiveDataFromISR();
    }
    
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_USART_1_RECEIVE);  
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_USART_1_TRANSMIT);
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_USART_1_ERROR);
}
コード例 #5
0
IntHandlerDrvTmrInstance2(void)
 
{
    StandardMessage msg;
    msg.data = 'L';
    xQueueSendFromISR(MsgQueue_MapEncoder_Interrupt, &msg, 0);
    
    //PLIB_PORTS_Write(PORTS_ID_0, PORT_CHANNEL_B, 'L');
    
    PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_TIMER_3);

}
コード例 #6
0
ファイル: main.c プロジェクト: ctapang/v0_70_01b
InputCaptureHandler(void)
{
    /* Clear the interrupt flag */
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_INPUT_CAPTURE_1);

    /* Make sure input capture buffer is full before performing a read */
    if (!PLIB_IC_BufferIsEmpty(IC_ID_1))
    {
        /* Store the value of the capture event into CaptureTime variable */
        CaptureTime = PLIB_IC_Buffer32BitGet(IC_ID_1);
    }
}
コード例 #7
0
//////////////////////////////////
// DN Communications Interrupts //
//////////////////////////////////
void __ISR(_UART2_RX_VECTOR, ipl7) _InterruptHandler_RS485_RX(void)
{
   /* Clear the interrupt flag */
   PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_USART_2_RECEIVE);

   /* Make sure receive buffer has data availible */
   if (PLIB_USART_ReceiverDataIsAvailable(USART_ID_2))
   {
      char data;

      /* Get the data from the buffer */
      data = PLIB_USART_ReceiverByteReceive(USART_ID_2);

      /* Echo what we just received */
      PutCharacter(data);
   }
   usartIntTriggered = true;
}
コード例 #8
0
ファイル: drv_adc_static.c プロジェクト: ECE4534-Team21/gary
// *****************************************************************************
// *****************************************************************************
// Section: ADC Static Driver Functions
// *****************************************************************************
// *****************************************************************************
void DRV_ADC_Initialize(void)
{
    /* Select Clock Source */
    PLIB_ADC_ConversionClockSourceSelect(DRV_ADC_ID_1, ADC_CLOCK_SOURCE_SYSTEM_CLOCK);
    /* Select Clock Prescaler */
    PLIB_ADC_ConversionClockSet(DRV_ADC_ID_1, SYS_CLK_FREQ, 320000000);

    /* Select Power Mode */
    PLIB_ADC_StopInIdleDisable(DRV_ADC_ID_1);
	
    /* Select Voltage Reference */
    PLIB_ADC_VoltageReferenceSelect(DRV_ADC_ID_1, ADC_REFERENCE_VDD_TO_AVSS);

    /* Sampling Selections */
    /* Select Sampling Mode */
    PLIB_ADC_SamplingModeSelect(DRV_ADC_ID_1, ADC_SAMPLING_MODE_MUXA);
    /* Number of Samples Per Interrupt */
    PLIB_ADC_SamplesPerInterruptSelect(DRV_ADC_ID_1, ADC_2SAMPLES_PER_INTERRUPT);

    /* Conversion Selections */
    /* Select Trigger Source */
    PLIB_ADC_ConversionTriggerSourceSelect(DRV_ADC_ID_1, ADC_CONVERSION_TRIGGER_INTERNAL_COUNT);
    /* Select Result Format */
    PLIB_ADC_ResultFormatSelect(DRV_ADC_ID_1, ADC_RESULT_FORMAT_INTEGER_16BIT);
    /* Buffer Mode */
    PLIB_ADC_ResultBufferModeSelect(DRV_ADC_ID_1, ADC_BUFFER_MODE_ONE_16WORD_BUFFER);

    /* Channel Selections */
    /* MUX A Negative Input Select */
    PLIB_ADC_MuxChannel0InputNegativeSelect(DRV_ADC_ID_1, ADC_MUX_A, ADC_INPUT_NEGATIVE_VREF_MINUS);
 

    /* MUX A Positive Input Select */
    PLIB_ADC_MuxChannel0InputPositiveSelect(DRV_ADC_ID_1, ADC_MUX_A, ADC_INPUT_POSITIVE_AN0);
 
    /* Initialize ADC Interrupt */
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_ADC_1);
    PLIB_INT_SourceEnable(INT_ID_0, INT_SOURCE_ADC_1);
    PLIB_INT_VectorPrioritySet(INT_ID_0, INT_VECTOR_AD1, INT_PRIORITY_LEVEL1);
    PLIB_INT_VectorSubPrioritySet(INT_ID_0, INT_VECTOR_AD1, INT_SUBPRIORITY_LEVEL0);	
}
コード例 #9
0
/******************************************************************************
  Function:
    SYS_PORTS_Initialize(void)

  Summary:
    Initializes Ports System Service

  Description:
    This function initializes different port pins/channels to the desired state.
    It also remaps the pins to the desired specific function.

  Remarks:
    None.
*/
void SYS_PORTS_Initialize(void)
{
    /* AN and CN Pins Initialization */
    PLIB_PORTS_AnPinsModeSelect(PORTS_ID_0, SYS_PORT_AD1PCFG, PORTS_PIN_MODE_DIGITAL);
    PLIB_PORTS_CnPinsPullUpEnable(PORTS_ID_0, SYS_PORT_CNPUE);
    PLIB_PORTS_CnPinsEnable(PORTS_ID_0, SYS_PORT_CNEN);
    PLIB_PORTS_ChangeNoticeEnable(PORTS_ID_0);

    PLIB_PORTS_Read(PORTS_ID_0, PORT_CHANNEL_D);
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_CHANGE_NOTICE);
    PLIB_INT_SourceEnable(INT_ID_0, INT_SOURCE_CHANGE_NOTICE);
    PLIB_INT_VectorPrioritySet(INT_ID_0, INT_VECTOR_CN, INT_PRIORITY_LEVEL2);
    PLIB_INT_VectorSubPrioritySet(INT_ID_0, INT_VECTOR_CN, INT_SUBPRIORITY_LEVEL0);


    /* PORT D Initialization */
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_ODC);
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_D,  SYS_PORT_D_LAT);
    PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_D,  SYS_PORT_D_TRIS ^ 0xFFFF);

}
コード例 #10
0
void __ISR(_TIMER_1_VECTOR, ipl1AUTO) IntHandlerDrvTmrInstance0(void)
{
    static uint16_t hb_cnt = 0, dsply_cnt = 10, input_cnt = 0;

    // Timer counter to set a flag that will cause the main loop to update
    // the heartbeat (status) LED.
    if (hb_cnt++ >= SYS_HB_MS / TMR0_TICK_MS)
    {
        hb_cnt = 0;
        hb_updt = true;
    }

    // Timer Counter to set a flag that will cause the main loop to scan the
    // inputs (pushbutton / dipswitch) used by the application.
    if (input_cnt++ >= INPUT_SCAN_MS / TMR0_TICK_MS)
    {
        input_cnt = 0;
        input_updt = true;
    }

    // Timer counter to set a flag that will cause the main loop to update the
    // OLED display.
    if (dsply_cnt++ >= DSPLY_UPDT_MS / TMR0_TICK_MS)
    {
        dsply_cnt = 0;
        dsply_updt = true;
    }

    // Timer counter to set a flag that will cause the display to be turned off
    // due to inactivity (not currently in use.)
    if (dsply_tmo_cnt++ >= DSPLY_TMO_MS / TMR0_TICK_MS)
    {
        dsply_tmo_cnt = DSPLY_TMO_MS / TMR0_TICK_MS;
    }

    // Clear the interrupt status flag.
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_TIMER_1);

}
コード例 #11
0
void IntHandlerDrvAdc(void)
{
    //TODO: make sure this corresponds to the Harmony config!!!
    int numberSamplesPerInterrupt = 1;
        
    //clear the interrupt flag
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_ADC_1);
    
    //get the ADC value
    unsigned int potValue = 0;
    int i = 0;
    for(i=0; i<numberSamplesPerInterrupt; i++)
        potValue += PLIB_ADC_ResultGetByIndex(ADC_ID_1, i);
    potValue = potValue/numberSamplesPerInterrupt; //the output is a 16-bit int
    
    //convert ADC steps to distance in cm
    //unsigned int distance = (unsigned int) (63.404-((double)potValue*0.058)); //cm
    unsigned int distance = (unsigned int) (24.952-((double)potValue*0.0227)); //in
    
    //send the value to the queue
    sendValToSensorTaskFromISR(&distance);
}
コード例 #12
0
void IntHandlerDrvAdc(void)
{
    DRV_ADC_Stop();
    //TODO: make sure this corresponds to the Harmony config!!!
    int numSamp = 6;
        
    //clear the interrupt flag
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_ADC_1);
    //get the ADC value
    unsigned int potValue = 0;
    unsigned int potValue1 = 0;
    unsigned int potValue2 = 0;
    unsigned int potValue3 = 0;
    unsigned int potValue4 = 0;
    unsigned int potValue5 = 0;
    int i = 0;
    
        for(i=0;i<numSamp;i+=numSamp)
    {
        potValue4 += DRV_ADC_SamplesRead(i);
        potValue += DRV_ADC_SamplesRead(i+1);
        potValue1 += DRV_ADC_SamplesRead(i+2);
        potValue3 += DRV_ADC_SamplesRead(i+3);
        potValue2 += DRV_ADC_SamplesRead(i+4);
        potValue5 += DRV_ADC_SamplesRead(i+5);
    }
    /*
    for(i=0; i<numberSamplesPerInterrupt; i += 3) {
        //potValue += PLIB_ADC_ResultGetByIndex(ADC_ID_1, i);
        potValue += DRV_ADC_SamplesRead(i);
        potValue1 += DRV_ADC_SamplesRead(i+1);
        potValue2 += DRV_ADC_SamplesRead(i+2);
    }
     * */
    //potValue = potValue/numberSamplesPerInterrupt; //the output is a 16-bit int
    
    unsigned int distance;
    unsigned int distance2;
    
    //convert ADC steps to distance in cm
    // distance = (unsigned int) (63.404-((double)potValue*0.058)); //cm
    // distance = (unsigned int) (24.952-((double)potValue*0.0227)); //in
    
    //distance = (unsigned int) potValue;
    //distance = distance & 0xFF;
    
    // DIST 
    if (potValue < 89)
        distance = 40;
    else
        distance = (unsigned int) (3530.0 / ((double)potValue));
    
    if (potValue5 < 89)
        distance2 = 40;
    else
        distance2 = (unsigned int) (3530.0 / ((double)potValue5));
    
    if (potValue2 < 833) potValue2 = 0;
    else potValue2 = potValue2 - 832;

    char data[MSG_LENGTH];
    data[0] = MSG_START;          // Start byte
    data[1] = TYPE_ADC;               // Type byte
    data[2] = 0x20;              // Count byte
    data[3] = distance & 0xFF;           
    data[4] = (potValue1 & 0x03FC) >> 2;  //FRONT
    data[5] = (potValue2 & 0x03FC) >> 2;  //REAR
    data[6] = (potValue3 & 0x03FC) >> 2;  //RIGHT
    data[7] = (potValue4 & 0x03FC) >> 2;  //LEFT
    data[8] = distance2 & 0xFF;           
    data[9] = MSG_STOP;           // Stop byte
    
    if (SEND_ADC == 0x1)
       putMsgOnSendQueue(data);
 
    //send the value to the queue
    sendValToSensorTaskFromISR(data);
    
    //PLIB_ADC_SampleAutoStartEnable(ADC_ID_1);
    
}
コード例 #13
0
/******************************************************************************
  Function:
    SYS_PORTS_Initialize(void)

  Summary:
    Initializes Ports System Service

  Description:
    This function initializes different port pins/channels to the desired state.
    It also remaps the pins to the desired specific function.

  Remarks:
    None.
*/
void SYS_PORTS_Initialize(void)
{
    /* PORT A Initialization */
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_A, SYS_PORT_A_ODC);
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_A,  SYS_PORT_A_LAT);
    PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_A,  SYS_PORT_A_TRIS ^ 0xFFFF);
    PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_A);
    PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_A, SYS_PORT_A_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL);
    PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_A, SYS_PORT_A_CNEN);
    PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_A, SYS_PORT_A_CNPU);
    PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_A, SYS_PORT_A_CNPD);
    
    /* PORT B Initialization */
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_ODC);
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_B,  SYS_PORT_B_LAT);
    PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_B,  SYS_PORT_B_TRIS ^ 0xFFFF);
    PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_B);
    PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL);
    PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_CNEN);
    PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_CNPU);
    PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_B, SYS_PORT_B_CNPD);
    
    /* PORT C Initialization */
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_C, SYS_PORT_C_ODC);
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_C,  SYS_PORT_C_LAT);
    PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_C,  SYS_PORT_C_TRIS ^ 0xFFFF);
    PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_C);
    PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_C, SYS_PORT_C_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL);
    PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_C, SYS_PORT_C_CNEN);
    PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_C, SYS_PORT_C_CNPU);
    PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_C, SYS_PORT_C_CNPD);
    
    /* PORT D Initialization */
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_ODC);
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_D,  SYS_PORT_D_LAT);
    PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_D,  SYS_PORT_D_TRIS ^ 0xFFFF);
    PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_D);
    PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL);
    PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_CNEN);
    PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_CNPU);
    PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_D, SYS_PORT_D_CNPD);
    
    /* PORT E Initialization */
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_E, SYS_PORT_E_ODC);
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_E,  SYS_PORT_E_LAT);
    PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_E,  SYS_PORT_E_TRIS ^ 0xFFFF);
    PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_E);
    PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_E, SYS_PORT_E_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL);
    PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_E, SYS_PORT_E_CNEN);
    PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_E, SYS_PORT_E_CNPU);
    PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_E, SYS_PORT_E_CNPD);
    
    /* PORT F Initialization */
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_F, SYS_PORT_F_ODC);
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_F,  SYS_PORT_F_LAT);
    PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_F,  SYS_PORT_F_TRIS ^ 0xFFFF);
    PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_F);
    PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_F, SYS_PORT_F_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL);
    PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_F, SYS_PORT_F_CNEN);
    PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_F, SYS_PORT_F_CNPU);
    PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_F, SYS_PORT_F_CNPD);
    PLIB_PORTS_Read(PORTS_ID_0, PORT_CHANNEL_F);    
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_CHANGE_NOTICE_F);         
    PLIB_INT_SourceEnable(INT_ID_0, INT_SOURCE_CHANGE_NOTICE_F);
    PLIB_INT_VectorPrioritySet(INT_ID_0, INT_VECTOR_CHANGE_NOTICE_F, INT_PRIORITY_LEVEL1);
    PLIB_INT_VectorSubPrioritySet(INT_ID_0, INT_VECTOR_CHANGE_NOTICE_F, INT_SUBPRIORITY_LEVEL0);
    
    /* PORT G Initialization */
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_G, SYS_PORT_G_ODC);
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_G,  SYS_PORT_G_LAT);
    PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_G,  SYS_PORT_G_TRIS ^ 0xFFFF);
    PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_G);
    PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_G, SYS_PORT_G_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL);
    PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_G, SYS_PORT_G_CNEN);
    PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_G, SYS_PORT_G_CNPU);
    PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_G, SYS_PORT_G_CNPD);
    
    /* PORT H Initialization */
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_H, SYS_PORT_H_ODC);
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_H,  SYS_PORT_H_LAT);
    PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_H,  SYS_PORT_H_TRIS ^ 0xFFFF);
    PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_H);
    PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_H, SYS_PORT_H_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL);
    PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_H, SYS_PORT_H_CNEN);
    PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_H, SYS_PORT_H_CNPU);
    PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_H, SYS_PORT_H_CNPD);
    
    /* PORT J Initialization */
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_J, SYS_PORT_J_ODC);
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_J,  SYS_PORT_J_LAT);
    PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_J,  SYS_PORT_J_TRIS ^ 0xFFFF);
    PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_J);
    PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_J, SYS_PORT_J_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL);
    PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_J, SYS_PORT_J_CNEN);
    PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_J, SYS_PORT_J_CNPU);
    PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_J, SYS_PORT_J_CNPD);
    
    /* PORT K Initialization */
    PLIB_PORTS_OpenDrainEnable(PORTS_ID_0, PORT_CHANNEL_K, SYS_PORT_K_ODC);
    PLIB_PORTS_Write( PORTS_ID_0, PORT_CHANNEL_K,  SYS_PORT_K_LAT);
    PLIB_PORTS_DirectionOutputSet( PORTS_ID_0, PORT_CHANNEL_K,  SYS_PORT_K_TRIS ^ 0xFFFF);
    PLIB_PORTS_ChangeNoticePerPortTurnOn(PORTS_ID_0, PORT_CHANNEL_K);
    PLIB_PORTS_ChannelModeSelect(PORTS_ID_0, PORT_CHANNEL_K, SYS_PORT_K_ANSEL ^ 0xFFFF, PORTS_PIN_MODE_DIGITAL);
    PLIB_PORTS_ChannelChangeNoticeEnable(PORTS_ID_0, PORT_CHANNEL_K, SYS_PORT_K_CNEN);
    PLIB_PORTS_ChannelChangeNoticePullUpEnable(PORTS_ID_0, PORT_CHANNEL_K, SYS_PORT_K_CNPU);
    PLIB_PORTS_ChannelChangeNoticePullDownEnable(PORTS_ID_0, PORT_CHANNEL_K, SYS_PORT_K_CNPD);


    /* PPS Input Remapping */
    PLIB_PORTS_RemapInput(PORTS_ID_0, INPUT_FUNC_SDI6, INPUT_PIN_RPB14 );
    PLIB_PORTS_RemapInput(PORTS_ID_0, INPUT_FUNC_U4RX, INPUT_PIN_RPD5 );
    PLIB_PORTS_RemapInput(PORTS_ID_0, INPUT_FUNC_SDI2, INPUT_PIN_RPG7 );
    PLIB_PORTS_RemapInput(PORTS_ID_0, INPUT_FUNC_U1RX, INPUT_PIN_RPG1 );
    PLIB_PORTS_RemapInput(PORTS_ID_0, INPUT_FUNC_U3RX, INPUT_PIN_RPF5 );
    PLIB_PORTS_RemapInput(PORTS_ID_0, INPUT_FUNC_SDI1, INPUT_PIN_RPD2 );

    /* PPS Output Remapping */
    PLIB_PORTS_RemapOutput(PORTS_ID_0, OUTPUT_FUNC_SDO6, OUTPUT_PIN_RPB15 );
    PLIB_PORTS_RemapOutput(PORTS_ID_0, OUTPUT_FUNC_U4TX, OUTPUT_PIN_RPD4 );
    PLIB_PORTS_RemapOutput(PORTS_ID_0, OUTPUT_FUNC_SDO2, OUTPUT_PIN_RPG8 );
    PLIB_PORTS_RemapOutput(PORTS_ID_0, OUTPUT_FUNC_U1TX, OUTPUT_PIN_RPG0 );
    PLIB_PORTS_RemapOutput(PORTS_ID_0, OUTPUT_FUNC_U3TX, OUTPUT_PIN_RPA14 );
    PLIB_PORTS_RemapOutput(PORTS_ID_0, OUTPUT_FUNC_SDO1, OUTPUT_PIN_RPD3 );

    
}
コード例 #14
0
ファイル: POEpwm.c プロジェクト: godzivan/PIC32POEnetNode
void PWM2_SetValues(
    TMR_PRESCALE pwmPreScale
,   int pwmCycle
,   int pwmStart1
,   int pwmStop1
,   int pwmStart2
,   int pwmStop2
) {
    if ((pwmPreScale == TMR_PRESCALE_VALUE_1) & (pwmCycle < 400)) {
        PWM2_doInt = false;
    }
    if ((pwmPreScale != PWM2_PreScale) | !PWM2_doInt) {
        // total update
        // Disable Interrupt / Clear Flag
        PLIB_INT_SourceDisable(APP_INT_ID, APP_PWM2_TMR_INT_SOURCE);
        PLIB_INT_SourceFlagClear(APP_INT_ID, APP_PWM2_TMR_INT_SOURCE);
        // Stop the timer
        PLIB_TMR_Stop(APP_PWM2_TMR_ID);
        // Disable OC's
        PLIB_OC_Disable(APP_PWM2_OC1_ID);
#ifdef APP_PWM2_OC2_ID
        PLIB_OC_Disable(APP_PWM2_OC2_ID);
#endif // ifdef APP_PWM2_OC2_ID
        PWM2_PreScale = pwmPreScale;
        PWM2_Cycle = pwmCycle;
        PWM2_Start1 = pwmStart1;
        PWM2_Stop1 = pwmStop1;
        PWM2_Start2 = pwmStart2;
        PWM2_Stop2 = pwmStop2;
        // Set the prescaler, and set the clock source as internal
        PLIB_TMR_PrescaleSelect(APP_PWM2_TMR_ID, pwmPreScale);
        // Clear the timer
        PLIB_TMR_Counter16BitClear(APP_PWM2_TMR_ID);
        // Load the period register
        PLIB_TMR_Period16BitSet(APP_PWM2_TMR_ID, pwmCycle);
        // OC1 Init
        // Set buffer(primary compare) value
        PLIB_OC_Buffer16BitSet(APP_PWM2_OC1_ID, pwmStart1);
        // Set pulse width(secondary compare) value
        PLIB_OC_PulseWidth16BitSet(APP_PWM2_OC1_ID, pwmStop1);
#ifdef APP_PWM2_OC2_ID
        // OC2 Init
        // Set buffer(primary compare) value
        PLIB_OC_Buffer16BitSet(APP_PWM2_OC2_ID, pwmStart2);
        // Set pulse width(secondary compare) value
        PLIB_OC_PulseWidth16BitSet(APP_PWM2_OC2_ID, pwmStop2);
#endif // ifdef APP_PWM2_OC2_ID
        // Enable OC 1
        PLIB_OC_Enable(APP_PWM2_OC1_ID);
#ifdef APP_PWM2_OC2_ID
        // Enable OC 2
        PLIB_OC_Enable(APP_PWM2_OC2_ID);
#endif // ifdef APP_PWM2_OC2_ID
        if ((PWM2_PreScale == TMR_PRESCALE_VALUE_1) & (PWM2_Cycle < 400)) {
            PWM2_doInt = false;
        } else {
            PWM2_doInt = true;
            // Reenable Interrupt
            PLIB_INT_SourceEnable(APP_INT_ID, APP_PWM2_TMR_INT_SOURCE);
        }
        // Start the timer
        PLIB_TMR_Start(APP_PWM2_TMR_ID);
    } else {
        // continuos update
        PWM2_Cycle = pwmCycle;
        PWM2_Start1 = pwmStart1;
        PWM2_Stop1 = pwmStop1;
        PWM2_Start2 = pwmStart2;
        PWM2_Stop2 = pwmStop2;
    } 
}
コード例 #15
0
ファイル: main.c プロジェクト: ctapang/v0_70_01b
TimerHandler(void)
{
    /* Clear the interrupt flag */
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_TIMER_1);
}
コード例 #16
0
// *****************************************************************************
// *****************************************************************************
// Section: System Interrupt Vector Functions
// *****************************************************************************
// *****************************************************************************
void IntHandlerDrvOCInstance0(void)

{
    PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_OUTPUT_COMPARE_1);

}