Gast
#1632332
hier ist ein ausschnitt aus dem programm, welches für pic18f1320
geshrieben ist (mplab c18 compiler), funktioniert leider nicht, oder ich
mache alles falsch. das ziel ist für die ausgerechnete zeit p1 in µs
eine dynamische pause organiesieren. Quarz ist 32MHZ. ich wolte das
ganze über tmr0 machen aber das ganze funktioniert nicht. die pausen
werden nicht eingehalten. bitte nicht lachen, wenn das alles falsch ist,
bin nur anfänger.
danke
#include <p18f1320.h>
#include <timers.h>
#pragma config OSC = HS //CPU=32 MHz
#pragma config PWRT = ON
#pragma config BOR = OFF
#pragma config WDT = OFF
#pragma config LVP = OFF
unsigned long int p1=31622000;
long double p;
long double r=5E-10;
long int l;
unsigned int k,j,i,s;
unsigned int f;
TRISB=0b11110000;
ADCON1 = 0x7f;
while(1)
{
p=p1*(1-r*p1*p1);
p1=p;
l=(long int)p1;
k=(long int)(l/65535);
s=(long int)(l%65536);
LATB=0x05;
for(i=0;i<k;i++){
INTCONbits.TMR0IF=0;
T0CONbits.TMR0ON=0;
T0CONbits.T08BIT = 0;
T0CONbits.T0CS = 0;
T0CONbits.PSA = 0;
T0CONbits.T0PS2 = 0;
T0CONbits.T0PS1 = 1;
T0CONbits.T0PS0 = 0;
INTCONbits.TMR0IE =0;
INTCONbits.TMR0IF=0;
WriteTimer0(65535);
T0CONbits.TMR0ON = 1;
while(!INTCONbits.TMR0IF)
INTCONbits.TMR0IF=0;
T0CONbits.TMR0ON=0;
}
f=(65535-s);
INTCONbits.TMR0IF=0;
T0CONbits.TMR0ON = 0;
T0CONbits.T08BIT = 0;
T0CONbits.T0CS = 0;
T0CONbits.PSA = 0;
T0CONbits.T0PS2 = 0;
T0CONbits.T0PS1 = 1;
T0CONbits.T0PS0 = 0;
INTCONbits.TMR0IE = 0;
INTCONbits.TMR0IF=0;
T0CONbits.TMR0ON = 1;
WriteTimer0(f);
T0CONbits.TMR0ON = 1;
while(!INTCONbits.TMR0IF)
INTCONbits.TMR0IF=0;
T0CONbits.TMR0ON=0;
p=p1*(1-r*p1*p1);
p1=p;
l=(long int)p1;
k=(long int)(l/65535);
s=(long int)(l%65536);
LATB=0x06
for(i=0;i<k;i++){
INTCONbits.TMR0IF=0;
T0CONbits.TMR0ON=0;
T0CONbits.T08BIT = 0;
T0CONbits.T0CS = 0;
.
.
.
}