Calculatrice picdem 2 plus (pic16f1937)

Fermé
kev5016 - 25 août 2015 à 23:14
ASO14 Messages postés 5 Date d'inscription mardi 8 septembre 2015 Statut Membre Dernière intervention 2 mai 2016 - 8 sept. 2015 à 19:55
Bonjour,


voici mon programme!
"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pic16f1937.h>
#include <xc.h>

#define _XTAL_FREQ 8000000

// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection (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 CPD = OFF // Data Memory Code Protection (Data 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)
#pragma config IESO = OFF // Internal/External Switchover (Internal/External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is disabled)

// CONFIG2
#pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
#pragma config VCAPEN = OFF // Voltage Regulator Capacitor Enable (All VCAP pin functionality is disabled)
#pragma config PLLEN = ON // PLL Enable (4x PLL enabled)
#pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = HI // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), high trip point selected.)
#pragma config LVP = ON // Low-Voltage Programming Enable (Low-voltage programming enabled)

#define CLEAR_SCREEN 0b00000001
#define LINES_5X8 0b00111000
#define CURSOR_BLINK 0b00001111
#define CURSOR_RIGHT 0b00011100
#define DATA_PORT PORTD
#define RS_PIN PORTAbits.RD4
#define E1_PIN PORTAbits.RD6


void init(void)
{
//init PORTS
PORTA = 0b00000000; // initial values
PORTB = 0b00000000;
PORTC = 0b01000000;
PORTD = 0b00001111;
PORTE = 0b00000000;

TRISA = 0b00101111; // set outputs or input
TRISB = 0b11111100;
TRISC = 0b00011100;
TRISD = 0b00000000;
TRISE = 0b00000111;

ANSELA = 0b00101111; // enable analog inputs
ANSELB = 0b00110000;
ANSELD = 0b00000000;
ANSELE = 0b00000110;


//init USART
TXSTA = 0b00100100; // 8-bit, tx-enb, asynch, BRGH=1
SPBRG = 51; // 9600 baud with 8MHz clock. Table 12-5 in datasheet
RCSTA = 0b10010000; // SPEN=1, CREN=1, addr-det disabled.
}


void SetAddr(unsigned char DDaddr)
{
RD4 = 0;
RD6=1; // Enable LCD

PORTD= DDaddr;
__delay_ms(3);
RD6=0; // Enable LCD

__delay_ms(1);
}

void WriteCmd(unsigned char cmd)
{
RD4 = 0;
RD6=1; // Enable LCD

PORTD=cmd; //
__delay_ms(3);
RD6=0; // Enable LCD

__delay_ms(1);
}


void WriteChar(char data)
{
RD4 = 1;
RD6=1; // Enable LCD

PORTD=data; //
__delay_ms(3);
RD6=0; // Enable LCD

__delay_ms(1);
}



void WriteString(const char *buffer)
{
while(*buffer)
{
WriteChar(*buffer);
buffer++;
}
return;
}

void init_disp(void)
{
WriteCmd(0x30); // Initialize first 2 rows
__delay_ms(10);
WriteCmd(0x30);
__delay_ms(10);
WriteCmd(0x30);
__delay_ms(10);
WriteCmd(0x3c);
__delay_ms(3);
WriteCmd(0x0f);
__delay_ms(3);
WriteCmd(0x01);
__delay_ms(3);

}

void ecrire_1();
void ecrire_2();
void ecrire_3();
void ecrire_4();


void clavier(void)
{
RC4=1;
RC3=1;
RC5=1;
RC6=1;
__delay_us(200);
RC4=0;
ecrire_1(1);
__delay_us(300);
RC3=0;
ecrire_2(2);
__delay_us(300);
RC5=0;
ecrire_3(3);
__delay_us(300);
RC6=0;
ecrire_4(4);
__delay_us(300);
}

void ecrire_1(void)
{
if (RB0=0)
{
WriteString(0);
}

if (RB1=0)
{
WriteString(1);
}

if (RB2=0)
{
WriteString(4);
}

if (RB3=0)
{
WriteString(7);
}

else //(RB0,RB1,RB2,RB3=1)
{
;
}

}


void ecrire_2(void)
{
if (RB0=0)
{
WriteString(0xb8);
}

if (RB1=0)
{
WriteString(2);
}

if (RB2=0)
{
WriteString(5);
}

if (RB3=0)
{
WriteString(8);
}

else //(RB0,RB1,RB2,RB3=1)
{
;
}
}

void ecrire_3(void)
{
if (RB0=0)
{
WriteString(0x3d);
}

if (RB1=0)
{
WriteString(3);
}

if (RB2=0)
{
WriteString(6);
}

if (RB3=0)
{
WriteString(9);
}

else //(RB0,RB1,RB2,RB3=1)
{
;
}
}

void ecrire_4(void)
{
if (RB0=0)
{
WriteString(0x2b);
}

if (RB1=0)
{
WriteString(0x2d);
}

if (RB2=0)
{
WriteString(0x2a);
}

if (RB3=0)
{
WriteString(0x2f);
}

else //(RB0,RB1,RB2,RB3=1)
{
;
}
}

"

et le defaux que j'ai:
"
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/Pc/Documents/PRO/programation/c/calcule.X'
make -f nbproject/Makefile-default.mk dist/default/production/calcule.X.production.hex
make[2]: Entering directory 'C:/Users/Pc/Documents/PRO/programation/c/calcule.X'
"C:\Program Files (x86)\Microchip\xc8\v1.34\bin\ xc8.exe" --chip=16F1937 -G -mdist/default/production/calcule.X.production.map --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" --memorysummary dist/default/production/memoryfile.xml -odist/default/production/calcule.X.production.elf build/default/production/newmain.p1
Microchip MPLAB XC8 C Compiler (Free Mode) V1.34
Build date: Feb 16 2015
Part Support Version: 1.34
Copyright (C) 2015 Microchip Technology Inc.
License type: Node Configuration

:: warning: (1273) Omniscient Code Generation not available in Free mode
make[2]: *** [dist/default/production/calcule.X.production.hex] Error 1
Non line specific message:: error: (1091) main function "_main" not defined
(908) exit status = 1
nbproject/Makefile-default.mk:119: recipe for target 'dist/default/production/calcule.X.production.hex' failed
make[2]: Leaving directory 'C:/Users/Pc/Documents/PRO/programation/c/calcule.X'
nbproject/Makefile-default.mk:78: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/Pc/Documents/PRO/programation/c/calcule.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 605ms)

"
j'utilise MPLAB IDE X avec un debugger MPLAB ICD 3 connecter a une carte de développement PICDEM 2 plus 2010 avec dessus un pic16f1937

Réponse en mode avancé Répondre Réponse rapide à ce message Réponse rapide Répondre avec citation Répondre avec citation Multi-citer ce message



+ Répondre à la discussion
Navigation rapide Électronique Haut de page
« Exercice amplificateur basse fréquence | - »
Discussions similaires

Picdem 2+ buzzer
Par Madajis dans le forum Électronique
Réponses: 0
Dernier message: 16/09/2014, 16h35
LCD du picdem 2+ rouge
Par jeannette74 dans le forum Électronique
Réponses: 1
Dernier message: 06/06/2012, 22h38
Picdem 2plus
Par enrique1 dans le forum Électronique
Réponses: 6
Dernier message: 13/12/2009, 04h29
picdem 1 (PIC 16F627)
Par monahf dans le forum Électronique
Réponses: 1
Dernier message: 31/10/2009, 17h43
PICDem 2 plus - C18 et LCD
Par hoffmann dans le forum Électronique
Réponses: 5
Dernier message: 07/10/2008, 20h35

Nous contacter
Sciences
Archives
Haut de page

Fuseau horaire GMT +2. Il est actuellement 23h12. Powered by vBulletin®
Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.
SEO by vBSEO ©2011, Crawlability, Inc.
Traduction by association vBulletin francophone (www.vbulletin-fr.org)
Skin by CompleteVB / FS



A voir également:

1 réponse

ASO14 Messages postés 5 Date d'inscription mardi 8 septembre 2015 Statut Membre Dernière intervention 2 mai 2016
8 sept. 2015 à 19:55
Pouviez-vous être un peu plus claire ?
0