Development Tool: MPLAB X v5.1(MCC v3.66)
Compiler: XC8 v2.0
Device: PIC16F1827
I2C Master: SCL(RB4 - 10pin), SDA(RB1 - 7pin)
I2C Slave: SCL(RB5 - 11pin), SDA(RB2 - 8pin)
void main(void) { // initialize the device SYSTEM_Initialize(); // When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits // Use the following macros to: // Enable the Global Interrupts INTERRUPT_GlobalInterruptEnable(); // Enable the Peripheral Interrupts INTERRUPT_PeripheralInterruptEnable(); // Disable the Global Interrupts //INTERRUPT_GlobalInterruptDisable(); // Disable the Peripheral Interrupts //INTERRUPT_PeripheralInterruptDisable(); while (1) { wrBuffer[0] = 0x0A; wrBuffer[1] = 0x0B; wrBuffer[2] = 0x0C; I2C1_MasterWrite( wrBuffer, 1, 0x08, &status); while(status == I2C1_MESSAGE_PENDING); I2C1_MasterRead( rdBuffer, 3, 0x08, &status); while(status == I2C1_MESSAGE_PENDING); __delay_ms(500); } } |
I2C Output waveform
I2C Output waveform
INTERRUPT_GlobalInterruptEnable() and INTERRUPT_PeripheralInterruptEnable() have to comment out due to I2C Master and I2C Slave are using interrupt service routine
I2C Pin allocation for I2C1, I2C2
'MCU Basic' 카테고리의 다른 글
MPLAB X, XC8 Compiler 다운로드 링크 (0) | 2019.01.15 |
---|---|
마이크로칩 개발환경 최신버전 다운로드하기 (0) | 2019.01.15 |
Pickit4 연결 방법(ISCP 연결방법) (0) | 2019.01.14 |
Pickit3 연결 방법(ISCP 연결방법) (0) | 2019.01.14 |
ARM Cortex Family에 대한 기본 이해 (0) | 2019.01.14 |