hi, ich möchte eine wait-funktion in c mit einem Timer erstellen. dazu habe ihc es wie folgt gemacht
1 | ... |
2 | #define wait_flag = 0x00; |
3 | ... |
4 | |
5 | void wait(unsigned int count); |
6 | void Timer1_Init(void); |
7 | void __attribute__((interrupt, no_auto_psv)) _T1Interrupt(void); |
8 | ... |
9 | |
10 | int main (void){
|
11 | ... |
12 | ADPCFGbits.PCFG0 = 1; |
13 | TRISBbits.TRISB0 = 0; |
14 | LATBbits.LATB0 = 0; |
15 | ... |
16 | while(1){
|
17 | LATBbits.LATB0 = !LATBbits.LATB0; |
18 | wait(200); |
19 | } |
20 | } |
21 | |
22 | void wait(unsigned int count) |
23 | {
|
24 | unsigned int countzahl; |
25 | wait_flag = 1; |
26 | countzahl = count/(0,00000006781684027777780*256*1000); |
27 | PR1 = countzahl; |
28 | TMR1 = 0; // set timer to 0 |
29 | T1CONbits.TON = 1; |
30 | while(wait_flag!=0){ }
|
31 | } |
32 | |
33 | {
|
34 | // PR1 and TCKPS are set to call interrupt every 1000ms.´ |
35 | // Period = PR1 * prescaler * Tcy = 57600 * 256 * 67ns = 1000ms |
36 | T1CONbits.TON = 0; // Clear Timer 1 configuration |
37 | T1CONbits.TCKPS = 3; // Set timer 1 prescaler (0=1:1, 1=1:8, 2=1:64, 3=1:256) |
38 | T1CONbits.TSYNC = 1; // Synchronize external clock input (1: Synchronize, 0: Do not synchronize) |
39 | T1CONbits.TCS = 0; // Timer Clock Source bit (1: External clock from pin TxCK, 0: Internal clock (Fosc/4)) |
40 | //PR1 = 57600/2; // Set Timer 1 period (max value is 65535 (16 bit)) -> has to be set to 576 (10ms) |
41 | IPC0bits.T1IP = 1; // Set Timer 1 interrupt priority |
42 | IFS0bits.T1IF = 0; // Clear Timer 1 interrupt flag |
43 | IEC0bits.T1IE = 1; // Enable Timer 1 interrupt |
44 | //T1CONbits.TON = 1; // Turn on Timer 1 // made in _C1Interrupt(void) |
45 | } |
46 | |
47 | void __attribute__((interrupt, no_auto_psv)) _T1Interrupt(void) |
48 | {
|
49 | wait_flag = 0; |
50 | T1CONbits.TON = 0; // stopts timer |
51 | IFS0bits.T1IF = 0; // Clear Timer 1 interrupt flag |
52 | } |
aber er gibt mir den Fehler Main.c: In function 'wait': Main.c:84:5: error: lvalue required as left operand of assignment Main.c:85:26: error: invalid digit "8" in octal constant Main.c:85:25: warning: left-hand operand of comma expression has no effect Main.c: In function '_T1Interrupt': Main.c:111:5: error: lvalue required as left operand of assignment make[2]: *** [build/default/production/Main.o] Error 255 make[2]: *** Waiting for unfinished jobs.... nbproject/Makefile-default.mk:101: recipe for target 'build/default/production/Main.o' failed make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 was ist daran falsch? bzw. was bedeutet die Fehlermeldung?