Leker med en PIC18F4550 i C.
Försöker få till en statisk funktion men jag får kompileringsfel, är det någon skillnad på hur man skriver dessa i MPlab XC8 (2,36) mot "vanlig" C/Atmel?
Fellmedelandet är: error: function declared in block scope cannot have 'static' storage class
Har prövat lägga static före/efter void eller int, lagt int, void eller tomt i parenteserna men samma fel.
header.h
Kod: Markera allt
alla andra konfigurationer finns ovan.
// CONFIG7L
#pragma config EBTR0 = OFF // Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF // Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR2 = OFF // Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR3 = OFF // Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)
// CONFIG7H
#pragma config EBTRB = OFF // Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
void LEDBlink();
#endif /* XC_HEADER_TEMPLATE_H */
Kod: Markera allt
#include "header.h"
void main(void) {
TRISBbits.TRISB0 = 0; // 0 = OUT // 1 = INPUT
TRISBbits.TRISB1 = 0;
TRISBbits.TRISB2 = 0;
TRISBbits.TRISB3 = 0;
TRISBbits.TRISB7 = 1;
while(1){
LEDBlink();
}
return;
}
Kod: Markera allt
#include "header.h"
static int LEDButtonBlinker();
void LEDBlink(){
static int LEDButtonBlinker();
}
static int LEDButtonBlinker(){
if (PORTBbits.RB7 == 1){
PORTBbits.RB0 = 1; //Turn on LED 0
PORTBbits.RB1 = 1; //Turn on LED 1
PORTBbits.RB2 = 1; //Turn on LED 2
PORTBbits.RB3 = 1; //Turn on LED 3
__delay_ms(500);
PORTBbits.RB0 = 0; //Turn off LED 0
PORTBbits.RB1 = 0; //Turn off LED 1
PORTBbits.RB2 = 0; //Turn off LED 2
PORTBbits.RB3 = 0; //Turn off LED 3
__delay_ms(500);
}
}