Ситуация такая, написал простенькую программу для PIC12F675. Программа компилируется без ошибок в MPLAB X там же в отладчике она работает как и должна. Далее загружаю полученный hex в proteus и там... она работает неправильно. В чем дело не понял, ту же самую программу адаптировал для microC и получил такой же результат - в отладчике microC работает как и должна, а в proteus - опять неправильно. Попробовал загрузил в контроллер - результат как в proteus работает неправильно. Где искать причину. Не ругайте сильно я только начал программировать.
Спойлер
MPlabX v6.0Код: Выделить всё
/*
* File: main.c
* Author: Roo
*
* Created on 8 ??? 2022 ?., 11:29
*/
#include <stdio.h>
#include <stdlib.h>
/*
*
*/
// CONFIG
#pragma config FOSC = INTRCIO // Oscillator Selection bits (INTOSC oscillator: I/O function on GP4/OSC2/CLKOUT pin, I/O function on GP5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON // Power-Up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = ON // GP3/MCLR pin function select (GP3/MCLR pin function is MCLR)
#pragma config BOREN = ON // Brown-out Detect Enable bit (BOD enabled)
#pragma config CP = OFF // Code Protection bit (Program Memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#define _XTAL_FREQ 4000000 // Fosc frequency for _delay() library
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include <xc.h>
int main(int argc, char** argv) {
ANSEL = 0b00000000;
ADCON0 = 0b00000000;
nGPPU = 0b00000000;
WPU = 0b00000000;
TRISIO = 0b00001111;
GPIO = 0b00000000;
GIE = 0;
unsigned char Q = 0; //start status
while (1)
{
if (GPIO2) {
GPIO4 = 0;
GPIO5 = 1;
__delay_ms(500);
GPIO5 = 0;
__delay_ms(500); }
else if (!GPIO0 && GPIO1) {
GPIO4 = 0;
GPIO5 = 1; }
else if (GPIO0 && GPIO1) {
GPIO4 = 0;
GPIO5 = 0;
Q = 1; }
else if ((!GPIO0 && !GPIO1) || (GPIO0 && !GPIO1 && !Q)) {
GPIO4 = 1;
GPIO5 = 0;
Q = 0; }
}
return (EXIT_SUCCESS);
}
Спойлер
MicroC 6.2.1.0Код: Выделить всё
void main()
{
unsigned char Q=0; /*start status */
ANSEL = 0b00000000;
ADCON0 = 0b00000000;
/* GPPU = 0b00000000; */
WPU = 0b00000000;
TRISIO = 0b00001111;
GPIO = 0b00000000;
/* GIE = 0; */
while (1)
{
if (GPIO.GP2) {
// GPIO.GP4 = 0;
GPIO.GP4 = 0;
GPIO.GP5 = 1;
Delay_ms(500);
GPIO.GP5 = 0;
Delay_ms(500); }
else if (!GPIO.GP0 && GPIO.GP1) {
GPIO.GP4 = 0;
GPIO.GP5 = 1; }
else if (GPIO.GP0 && GPIO.GP1) {
GPIO.GP4 = 0;
GPIO.GP5 = 0;
Q = 1; }
else if ((!GPIO.GP0 && !GPIO.GP1) || (GPIO.GP0 && !GPIO.GP1 && !Q)) {
GPIO.GP4 = 1;
GPIO.GP5 = 0;
Q = 0; }
}
// return ();
}
