#include <stdio.h> #include <stdlib.h> #include <xc.h> // PIC16F1828 Configuration Bit Settings // CONFIG1 #pragma config FOSC = INTOSC // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin) #pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled) #pragma config PWRTE = OFF // Power-up Timer Enable (PWRT disabled) #pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input) #pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled) #pragma config CPD = OFF // Data Memory Code Protection (Data memory code protection is disabled) #pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled) #pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin) #pragma config IESO = OFF // Internal/External Switchover (Internal/External Switchover mode is disabled) #pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is disabled) // CONFIG2 #pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off) #pragma config PLLEN = OFF // PLL Enable (4x PLL disabled) #pragma config STVREN = OFF // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will not cause a Reset) #pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.) #pragma config LVP = OFF // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming) // クロック周波数指定 // __delay_ms()関数が使用する #define _XTAL_FREQ 1000000 int main(int argc, char** argv) { // PICマイコン設定 OSCCON = 0b01011010; // 内部クロック周波数を1MHzに設定 ANSELA = 0b00000000; // すべてのピンをデジタルモードに設定 TRISA = 0b00001000; // すべてのピンを出力モードに設定(ただしRA3ピンは常に入力モード) // 変数宣言 unsigned short timer; // 時間計測 unsigned short duty; // PWMのデューティーサイクル // 信号をPWM制御してスムーズな点滅制御をする // PWM機能のピン割り当て設定 APFCON1bits.CCP2SEL = 1; // PWM機能をRA5ピンに設定 CCP2CONbits.CCP2M = 0b1100; // PWM機能を有効、active-highに設定 CCP2CONbits.P2M = 0b00; // RA2ピンはGPIOに設定 // 周期(1ms)とデューティーサイクル(0.5ms)の設定 T2CONbits.T2CKPS = 0b00; // プリスケーラを1:1に設定 PR2 = 249; // 周期を5msに設定 (249 + 1) x 4 x 1us = 5ms CCPR2L = 500/4; // デューティーサイクルを0.5msに設定 CCP2CONbits.DC2B = 0; // PWM制御スタート T2CONbits.TMR2ON = 1; // LEDをPWM制御 // デューテー比は1%から99%の制御にする while(1) { // 1% -> 99%の制御 for(duty=10; duty<=990; duty++) { CCPR2L = duty / 4; // 上位8ビット CCP2CONbits.DC2B = duty; // 下位2ビット __delay_ms(1); } // 99% -> 1%の制御 for(duty=10; duty>=990; duty--) { CCPR2L = duty / 4; // 上位8ビット CCP2CONbits.DC2B = duty; // 下位2ビット __delay_ms(1); } } // 以下の命令は実行されない return (EXIT_SUCCESS); }
このプログラムにhttps://github.com/danjperron/GCrashの
i2cMaster.cとMPU6050.cという参考プログラムを追加したいのですが
どこにどう追加すればよいのかわかりません。
何通りか試したのですがエラーがかえってきて
うまくpicに取り込めません。
やり方を教えていただければと思います。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー