TUDOU2015 发表于 2015-6-19 15:27:10

关于MPLAB 的I/O口软件仿真的问题



我用截图中的程序仿真时能出现仿真波形,但是我把延时换成之前注释掉的延时重新编译后仿真,竟然没有波形真是匪夷所思,不知道哪里搞错了 ,请指导一下

TUDOU2015 发表于 2015-6-19 15:28:31


// PIC12F1572 Configuration Bit Settings

// 'C' source line config statements

#include <xc.h>
// #pragma config s tatements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

// CONFIG1
#pragma config FOSC = INTOSC    //(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 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)

// 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 LPBOREN = OFF    // Low Power Brown-out Reset enable bit (LPBOR is disabled)
#pragma config LVP = ON         // Low-Voltage Programming Enable (Low-voltage programming enabled)
#define uint unsigned int
#define uchar unsigned char
#defineIN_HIRA2
#defineIN_LORA0
void jiance();
void Delay_MS(uint n);
voidSysIinit();
void delay_us(uint n);
void Delay_MS(uint n)
{
    uint j;
    char k;
    for(j=0;j<n;j++)
      for(k=246;k>0;k--) NOP();
}
void delay_us(uint n)
{
    uint j;
    for(j=0;j<n;j++)
    NOP();
}

voidSysIinit()
{
    PORTA=0x00;
    LATA=0x00;
    TRISA=0x00;
    ANSELA=0x00;
    WPUA = 0x00;
//    OSCCON=0x7a;//16MHz
//    OSCCON=0xf2;//32MHz
//    OSCCON=0x72;//8MHz
    OSCCON=0x6a;//4MHz
}
void pulse()
{
   IN_HI=0;
   NOP();NOP();
//    Delay_MS(5);
   IN_LO=1;
    NOP();NOP();
//   Delay_MS(90);
   IN_LO=0;
    NOP();NOP();
//   Delay_MS(5);
   IN_HI=1;
//   Delay_MS(25);
    NOP();NOP();

}

void main()
{
SysIinit();
while(1)
{
   pulse();

}
}

zpywz 发表于 2015-6-19 19:24:41

看一下该IO的相关寄存器列表,关掉优先级高的功能,如模数转换、比较器等等。PIC就是点超烦。
页: [1]
查看完整版本: 关于MPLAB 的I/O口软件仿真的问题