?
hallo
ich begine erst mal was ich habe:
-Versuchsplatine, wo der PIC p18f1320 angeschlossen wird.
-eine Platine mit einer 4x7segment-Anzeige die über Multiplexing-Methode angesteuert wird
-einen DCF77 empfänger
Mein Freund und ich sollen alle 20 sec die anzeige wechseln lassen von min/std zu tag/monat zum Jahr anzeigen lassen.
Jedoch haben wird das problem das nix richtiges angezeigt wurd. und noch nicht mal die Synkronikation klapt da er sich zu oft zwischen drin resetet da er nicht alle werte die ankommen annimmt und ab und zu soagr werte annimmt die nicht da sind (mit Osziloskop nach geprüft)
(meiste zeit liegt 0,13V an steigt auf 4,6V für 100 oder 200 ms)
würde mich freuen wenn jemand wüsste wo dran es liegen könnte.
Programm:
//compilieren mit sdcc -mpic16 -p18f1320 Funkuhr.c
//include - Dateien
#include <pic18fregs.h>
#include <delay.h>
#pragma stack 0x80 0x32
//----------Konfigurationseinstellungen-------------------------------
code char at __CONFIG1H _conf0 = _IESO_OFF_1H & _FCMEN_OFF_1H & _OSC_XT_1H;
code char at __CONFIG2L _conf1 = _BODEN_OFF_2L & _PUT_OFF_2L;
code char at __CONFIG2H _conf2 = _WDT_DISABLED_CONTROLLED_2H;
code char at __CONFIG3H _conf3 = _MCLRE_MCLR_enabled_RA5_input_dis_3H;
code char at __CONFIG4L _conf4 = _STVR_OFF_4L & _LVP_OFF_4L & _BACKBUG_OFF_4L;
code char at __CONFIG5L _conf5 = _CP_0_OFF_5L & _CP_1_OFF_5L;
code char at __CONFIG5H _conf6 = _CPD_OFF_5H & _CPB_OFF_5H;
code char at __CONFIG6L _conf7 = _WRT_0_OFF_6L & _WRT_1_OFF_6L;
code char at __CONFIG6H _conf8 = _WRTD_OFF_6H & _WRTB_OFF_6H;
code char at __CONFIG7L _conf9 = _EBTR_0_OFF_7L & _EBTR_1_OFF_7L;
code char at __CONFIG7H _conf10 = _EBTRB_OFF_7H;
//------------------------------------------------------------------
unsigned char c,d,e,f,g;
unsigned char x=0,y=0;
unsigned char sig_wert,mez_mesz;
unsigned char mez=0,mesz=1;
unsigned char m;
unsigned char jah_e,jah_z;
unsigned char mon_e,mon_z;
unsigned char tag_e,tag_z;
unsigned char stu_e,stu_z;
unsigned char min_e,min_z;
char a[]={0,9,4,0,9,2,2,8,0,0,15};
char b[]={159,255,95,127,63,63,31,255,31,63,239};
void timer();
void ausgabe();
void auslese();
void schreiben();
//-----------------Auslese-timer-------------------------------------
void timer()
{
unsigned char z=0;
T0CON=128;
m = PORTAbits.RA4;
while(z<=10 && m==1)
{
TMR0H=64;
TMR0L=127;
while(INTCONbits.T0IF==0 && m==1)
{
ausgabe();
m = PORTAbits.RA4;
}
z++;
INTCONbits.T0IF=0;
m = PORTAbits.RA4;
}
if (z <= 8)
{
sig_wert = 1;
auslese();
x++;
}
if (z >= 10)
{
x = 0;
schreiben();
}
T0CON=0;
}
//------------------------------schreiben----------------------
void schreiben()
{
if (stu_e == 10 && mesz == 1)
{
stu_e = 0;
stu_z = stu_z + 1;
}
if (stu_e == 3 && stu_z == 2 && mesz == 1)
{
stu_e = 0;
stu_z = 0;
}
}
//------------------------------ausgabe----------------------
void ausgabe()
{
delay10tcy(25);
switch(x)
{
case 0: c = min_e;
d = min_z;
e = stu_e;
f = stu_z;
g = 1;
break;
case 1: min_e = 0;
min_z = 0;
stu_e = 0:
stu_z = 0;
break;
case 20: c = mon_e;
d = mon_z;
e = tag_e;
f = tag_z;
g = 1;
break;
case 21: mon_e = 0;
mon_z = 0;
tag_e = 0;
tag_z = 0;
break;
case 40: c = jah_e;
d = jah_z;
e = 0;
f = 2;
g = 0;
break;
case 41: jah_e = 0;
jah_z = 0;
break;
}
switch(y)
{
case 0: LATA = a[c];
LATB = b[c];
LATBbits.LATB0 = 0;
y=1;
break;
case 1: LATA = a[d];
LATB = b[d];
LATBbits.LATB1 = 0;
y=2;
break;
case 2: LATA = a[e];
LATB = b[e];
LATBbits.LATB2 = 0;
LATBbits.LATB4 = g;
y=3;
break;
case 3: LATA = a[f];
LATB = b[f];
LATBbits.LATB3 = 0;
y=0;
break;
}
}
//----------------------auslese----------------------------------
void auslese()
{
switch(x)
{
//------------------------------------Sommer oder Winter------------
case 16: sig_16 = sig_wert;
if(sig_16 == 0)
{
mez_mesz = 0;
}
if(sig_16 == 1)
{
mez_mesz = 1;
}
break;
case 17: sig_17 = sig_wert;
if(sig_17 == 1 && mez_mesz == 0)
{
mez = 0;
mesz = 1;
}
break;
case 18: sig_18 = sig_wert;
if(sig_18 == 1 && mez_mesz == 0)
{
mez = 1;
mesz = 0;
}
break;
//------------------------------Minuten------------------
case 21: if(sig_wert == 1) min_e = 1;
break;
case 22: if(sig_wert == 1) min_e = min_e + 2;
break;
case 23: if(sig_wert == 1) min_e = min_e + 4;
break;
case 24: if(sig_wert == 1) min_e = min_e + 8;
break;
case 25: if(sig_wert == 1) min_z = 1;
break;
case 26: if(sig_wert == 1) min_z = min_z + 2;
break;
case 27: if(sig_wert == 1) min_z = min_z + 4;
break;
//---------------------Stunde-----------------------------
case 29: if(sig_wert == 1) stu_e = 1;
break;
case 30: if(sig_wert == 1) stu_e = stu_e + 2;
break;
case 31: if(sig_wert == 1) stu_e = stu_e + 4;
break;
case 32: if(sig_wert == 1) stu_e = stu_e + 8;
break;
case 33: if(sig_wert == 1) stu_z = 1;
break;
case 34: if(sig_wert == 1) stu_z = stu_z + 2;
break;
//------------------Tag----------------------------------
case 36: if(sig_wert == 1) tag_e = 1;
break;
case 37: if(sig_wert == 1) tag_e = tag_e + 2;
break;
case 38: if(sig_wert == 1) tag_e = tag_e + 4;
break;
case 39: if(sig_wert == 1) tag_e = tag_e + 8;
break;
case 40: if(sig_wert == 1) tag_z = 1;
break;
case 41: if(sig_wert == 1) tag_z = tag_z + 2;
break;
//-----------------Monat---------------------------------
case 45: if(sig_wert == 1) mon_e = 1;
break;
case 46: if(sig_wert == 1) mon_e = mon_e + 2;
break;
case 47: if(sig_wert == 1) mon_e = mon_e + 4;
break;
case 48: if(sig_wert == 1) mon_e = mon_e + 8;
break;
case 49: if(sig_wert == 1) mon_z = 1;
break;
//-----------------Jahr---------------------------------
case 50: if(sig_wert == 1) jah_e = 1;
break;
case 51: if(sig_wert == 1) jah_e = jah_e + 2;
break;
case 52: if(sig_wert == 1) jah_e = jah_e + 4;
break;
case 53: if(sig_wert == 1) jah_e = jah_e + 8;
break;
case 54: if(sig_wert == 1) jah_z = 1;
break;
case 55: if(sig_wert == 1) jah_z = jah_z + 2;
break;
case 56: if(sig_wert == 1) jah_z = jah_z + 4;
break;
case 57: if(sig_wert == 1) jah_z = jah_z + 8;
break;
}
}
//---------------------------------------------------------------
void main()
{
ADCON1=127;
TRISA=16;
LATA = 255;
TRISB = 0;
LATB = 255;
while(1)
{
ausgabe();
m = PORTAbits.RA4;
if (m == 1)
{
timer();
}
}
}