/******************************************************************************* System Interrupts File Company: Microchip Technology Inc. File Name: interrupt.c Summary: Interrupt vectors mapping Description: This file maps all the interrupt vectors to their corresponding implementations. If a particular module interrupt is used, then its ISR definition can be found in corresponding PLIB source file. If a module interrupt is not used, then its ISR implementation is mapped to dummy handler. *******************************************************************************/ // DOM-IGNORE-BEGIN /******************************************************************************* * Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries. * * Subject to your compliance with these terms, you may use Microchip software * and any derivatives exclusively with Microchip products. It is your * responsibility to comply with third party license terms applicable to your * use of third party software (including open source software) that may * accompany Microchip software. * * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A * PARTICULAR PURPOSE. * * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. *******************************************************************************/ // DOM-IGNORE-END // ***************************************************************************** // ***************************************************************************** // Section: Included Files // ***************************************************************************** // ***************************************************************************** #include "configuration.h" #include "definitions.h" short int angleValue = 0; extern short int sinValue[360]; //sinテーブル値 extern DRV_HANDLE spi_Handle; DRV_SPI_TRANSFER_HANDLE transferHandle; //Handle which is returned by transfer add function. //実際での使用: 排他制御(Semaphore、Mutex)の実行に於いてなど // ***************************************************************************** // ***************************************************************************** // Section: System Interrupt Vector Functions // ***************************************************************************** // ***************************************************************************** void TIMER_1_InterruptHandler( void ); //記述追加 from MHC v.3_6_0 void SPI4_RX_InterruptHandler( void ); void SPI4_TX_InterruptHandler( void ); /* All the handlers are defined here. Each will call its PLIB-specific function. */ void __ISR(_TIMER_1_VECTOR, ipl1SRS) TIMER_1_Handler (void) { LATFbits.LATF2 = 0; //MCP4922 CS = 0 //送信データ送信 short int temp = (short int)(sinValue[angleValue] | 0b0001000000000000); //MP4922 制御コマンド //VoutAにゲイン2で出力 //MCP4922への書き込みコマンド //bit15(書き込みレジスタ選択)   1:VoutB   0:VoutA //bit14(予備) //bit13(出力ゲイン選択)  1:1倍   0:2倍  //bit12(出力オフ制御)  1:出力ON  0:出力OFF  //bit11?bit0 データ  MSBから順次送信される //★ SPI4のバッファーレジスタ SPI4BUFへの書き込み //1. Harmony V3 ライブラリ関数でSPIバッファーに書き込み DRV_SPI_WriteTransferAdd(spi_Handle, &temp, sizeof(temp), &transferHandle); //事前実行必須: DRV_SPI_Open(DRV_SPI_INDEX_0, DRV_IO_INTENT_WRITE);  at APP_Initialize() in app.c  ////2. プロジェクト内部関数でSPIバッファーに書き込み // SPI4_Initialize(); // SPI4_Write(&temp,sizeof(temp)); //事前実行必須: SPI4_Initialize(); at APP_Initialize() in app.c  //3. バッファレジスタ直接書き込み // SPI4BUF = temp; //SPI4のバッファーレジスタ SPI4BUFに直接書き込み delay_us(20); //MCP4922の処理待ち angleValue++; if(angleValue >= 360)angleValue = 0; LATFbits.LATF2 = 1; //MCP4922 CS = 1; // IFS0bits.T1IF = 0; //タイマ1割り込みフラグクリア TIMER_1_InterruptHandler(); //記述追加 from MHC v.3_6_0 } void __ISR(_SPI4_RX_VECTOR, ipl1SRS) SPI4_RX_Handler (void) { SPI4_RX_InterruptHandler(); } void __ISR(_SPI4_TX_VECTOR, ipl1SRS) SPI4_TX_Handler (void) { SPI4_TX_InterruptHandler(); } /******************************************************************************* End of File */