欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
PIC單片機(jī)編程學(xué)習(xí) 編譯出現(xiàn)錯誤,請求給予幫助
[打印本頁]
作者:
by64214
時間:
2018-11-7 22:30
標(biāo)題:
PIC單片機(jī)編程學(xué)習(xí) 編譯出現(xiàn)錯誤,請求給予幫助
PIC 編程學(xué)習(xí) 編譯 出現(xiàn)錯誤 請求給予幫助
編譯軟件 MPLAB X IDE v5.05 XC8 2.0 安裝在C: 新建工程在桌面 沒有中文出現(xiàn)
我在網(wǎng)上 找到例子
/*
* NEC Protocol IR remote control decoder with PIC16F887 MCU.
* C Code for MPLAB XC8 compiler.
* Internal oscillator used @ 8MHz.
* This is a free software with NO WARRANTY.
*/
// set configuration words
#pragma config CONFIG1 = 0x2CD4
#pragma config CONFIG2 = 0x0700
//LCD module connections
#define LCD_RS RD0
#define LCD_EN RD1
#define LCD_D4 RD2
#define LCD_D5 RD3
#define LCD_D6 RD4
#define LCD_D7 RD5
#define LCD_RS_DIR TRISD0
#define LCD_EN_DIR TRISD1
#define LCD_D4_DIR TRISD2
#define LCD_D5_DIR TRISD3
#define LCD_D6_DIR TRISD4
#define LCD_D7_DIR TRISD5
//End LCD module connections
#include <xc.h>
#define _XTAL_FREQ 8000000
#include <stdio.h> // for sprintf
#include <stdint.h> // include stdint header
#include "LCD_Lib.c" // include LCD driver source file
__bit nec_ok;
char text[5];
uint8_t nec_state, bit_n;
uint16_t timer_value;
uint32_t nec_code;
// interrupt ISRs
void __interrupt() EXT(void)
{
/*************** start external interrupt ISR ***************/
if (RBIF && (RB0 || !RB0)) // PORTB change ISR (& clear mismatch condition)
{
RBIF = 0; // clear PORTB interrupt flag bit
if(nec_state != 0)
{
timer_value = (TMR1H << 8) | TMR1L; // store Timer1 value
TMR1H = TMR1L = 0; // reset Timer1
}
switch(nec_state)
{
case 0 : // start receiving IR data (we're at the beginning of 9ms pulse)
TMR1H = TMR1L = 0; // reset Timer1
TMR1ON = 1; // enable Timer1
nec_state = 1; // next state: end of 9ms pulse (start of 4.5ms space)
bit_n = 0;
break;
case 1 : // End of 9ms pulse
if((timer_value > 9500) || (timer_value < 8500))
{ // invalid interval ==> stop decoding and reset
nec_state = 0; // reset decoding process
TMR1ON = 0; // disable Timer1
}
else
nec_state = 2; // next state: end of 4.5ms space (start of 562µs pulse)
break;
case 2 : // End of 4.5ms space
if((timer_value > 5000) || (timer_value < 4000))
{ // invalid interval ==> stop decoding and reset
nec_state = 0; // reset decoding process
TMR1ON = 0; // disable Timer1
}
else
nec_state = 3; // next state: end of 562µs pulse (start of 562µs or 1687µs space)
break;
case 3 : // End of 562µs pulse
if((timer_value > 700) || (timer_value < 400))
{ // invalid interval ==> stop decoding and reset
TMR1ON = 0; // disable Timer1
nec_state = 0; // reset decoding process
}
else
nec_state = 4; // next state: end of 562µs or 1687µs space
break;
case 4 :
if((timer_value > 1800) || (timer_value < 400))
{ // invalid interval ==> stop decoding and reset
TMR1ON = 0; // disable Timer1
nec_state = 0; // reset decoding process
}
else
{
if( timer_value > 1000) // if space width > 1ms (short space)
nec_code |= (uint32_t)1 << (31 - bit_n); // write 1 to bit (31 - bit_n)
else // if space width < 1ms (long space)
nec_code &= ~((uint32_t)1 << (31 - bit_n)); // write 0 to bit (31 - bit_n)
bit_n++;
if(bit_n > 31)
{
nec_ok = 1; // decoding process OK
RBIE = 0; // disable PORTB change interrupt
}
else
nec_state = 3; // next state: end of 562µs pulse (start of 562µs or 1687µs space)
break;
} // end " else "
} // end " switch(nec_state) "
} // end " if (RBIF && (RB0 || !RB0)) "
/*************** end external interrupt ISR ***************/
/*************** start Timer1 ISR ***************/
if (TMR1IF) // Timer1 ISR
{
TMR1IF = 0; // clear Timer1 overflow flag bit
nec_state = 0; // reset decoding process
TMR1ON = 0; // disable Timer1
}
/*************** end Timer1 ISR ***************/
}
/*************************** main function *********************/
void main(void)
{
OSCCON = 0x70; // set internal oscillator to 8MHz
ANSELH = 0; // configure all PORTB pins as digital
TMR1IF = 0; // clear Timer1 overflow interrupt flag bit
RBIF = 0; // clear PORTB change interrupt flag bit
TMR1IE = 1; // enable Timer1 overflow interrupt
T1CON = 0x10; // set Timer1 clock source to internal with 1:2 prescaler (Timer1 clock = 1MHz)
INTCON = 0xC8; // enable global, peripheral and PORTB change interrupts
IOCB0 = 1; // enable RB0 pin change interrupt
nec_ok = 0;
nec_state = 0;
__delay_ms(1000); // wait 1 second
LCD_Begin(); // initialize LCD module
LCD_Goto(1, 1); // move cursor to column 1, row 1
LCD_Print("Address:0x0000");
LCD_Goto(1, 2); // move cursor to column 1, row 2
LCD_Print("Com:0x00 In:0x00");
while(1)
{
while (!nec_ok); // wait until NEC code receiver
nec_ok = 0; // reset decoding process
nec_state = 0;
TMR1ON = 0; // disable Timer1
uint16_t address = nec_code >> 16;
uint8_t command = nec_code >> 8;
uint8_t inv_command = nec_code;
sprintf(text,"%04X",address);
LCD_Goto(11, 1); // move cursor to column 11 line 1
LCD_Print(text); // print address
sprintf(text,"%02X",command);
LCD_Goto(7, 2); // move cursor to column 7 line 2
LCD_Print(text); // print command
sprintf(text,"%02X",inv_command);
LCD_Goto(15, 2); // move cursor to column 15 line 2
LCD_Print(text); // print inverted command
RBIE = 1; // enable PORTB change interrupt
}
}
/*************************** end main function ********************************/
復(fù)制代碼
下載 新建工程加入 LCD_Lib.c
按照網(wǎng)上 PIC單片機(jī)入門教程(四)—— 第一個工程
https://blog.csdn.net/JYUNefe/article/details/80657918
步驟操作 并進(jìn)行芯片配置操作
結(jié)果 編譯 出現(xiàn)錯誤 大概意思是 LCD_RS 等 引腳沒有標(biāo)識 #include <xc.h> 顯示未解析的內(nèi)部包含文件
思考可能是 什么地方?jīng)]有設(shè)置
請求給予幫助
作者:
Y_G_G
時間:
2018-11-8 17:28
在頭文件中加一個包含PIC16F877A的語句,或者是直接改#define LCD_RS RD0 這個RD0直接用這個IO的地址,應(yīng)該是這樣的,沒有用過C,不知道,你試一下
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1