大家好,很难找出为什么我的PIC16F503是拖延(冻结,崩溃?)在MimcPy语句上。我没有调试头,所以我不得不依赖基本的调试和模拟器。我通过把一个LATA写在一个LED上,直到它不再工作,把它缩小到这个语句上。在模拟器里,我没有看到任何问题,它运行良好,完全符合我的期望。这发生在我的init函数中,这是第一个主要的东西,所以应该有。在这之前没有任何事情发生。想知道你们这里的专家是否能给我一些关于它停止的想法。我想可能是一个中断,但即使是GIE残疾人,也无法通过这个声明。谢谢!
以上来自于百度翻译
以下为原文
Hello all,
Having a hard
time figuring out why my PIC16F1503 is stalling (freezing, crashing?) on a memcpy statement. I don't have a debug header, so I'm forced to rely on basic debugging and the simulator. I narrowed it down to this statement by moving a LATA write around that turns on an LED until it no longer worked.
In the simulator I'm not seeing any issues, it runs fine and does exactly what I expect it to.
This happens within my Init function, which is the very first thing in main so there shouldn't be anything executing before this.
Wondering if any of you experts here could give me some ideas on what could be causing it to stop. I thought maybe an interrupt, but even with GIE disabled it fails to get past that statement.
Thank you!
#include
#include
#include
extern volatile char lcd_buffer[21];
void Init(void){
// Set Processor Frequency
// OSCCON - Oscillator Control Register
OSCCON = 0b01101000;
// Set Data Port Input/Output
ANSELA = 0x00; // Turn off Analog Input functionality
LATA = 0x00; // Set default Port A output values
TRISA = 0x23; // Set bits 2 and 4 as output
ANSELC = 0x00; // Turn off Analog Input functionality
TRISC = 0xFF; // Set all of Port C as input
// Configure I2C Registers
// SSP1STAT - SSP Status Register
SSP1CON1 = 0x28;
// SSP1CON2 - SSP Control Register 2
SSP1CON3 = 60;
// SSP1ADD - MSSP Address and Baud Rate Register
SSP1ADD = 0x09;
// Enable MSSP (I2C) Interrupts
PIE1bits.SSP1IE = 1;
// Enable Global Interrupts
INTCONbits.GIE = 1;
INTCONbits.PEIE = 1;
// Initialize the LCD
const uint8_t lcd_init1[] = {0x00,0x38,0x39,0x14,0x78,0x5E,0x6D};
memcpy(lcd_buffer,lcd_init1,7);
// More code follows, but this is where the LATA command fails to execute
}