Forum: Mikrocontroller und Digitale Elektronik config 16f887


von Andreas F. (andreas_fri)


Lesenswert?

Hallo alle Mitteinander,

könnt ihr mir bitte bei der Konfigurationd eines 16f887 helfen.
Ich bin sehr bewandt in C habe aber von ASM keinen Dunst,
aus diesem Grund bevorzuge ich C.

Als erstes ist das Config-Wort interessant.
Wie finde ich heraus auf welchem Register das Config-Wort liegt?

Die Pins will ich nur als digitale I/O konfigurieren.

Mit welchen Tools/IDE´s entwickelt ihr?

mfg Andreas

von Peter C. (peter_c49)


Lesenswert?

Hallo Andreas,

nimm die MPLABX IDE und den XC8 compiler.
dort kannst du das configword einsehen und bequem ändern,
dann "generate sourcecode" und in dein program cut-and-pasten.

zb, wie hier für einen ur-alten 8-bit pic typ den ich noch stangenweise 
rumliegen hab.
<code>
// PIC16F73 Configuration Bit Settings

#include <xc.h>

// CONFIG
#pragma config FOSC = RC        // Oscillator Selection bits (RC 
oscillator)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT 
disabled)
#pragma config PWRTE = ON       // Power-up Timer Enable bit (PWRT 
enabled)
#pragma config CP = OFF         // FLASH Program Memory Code Protection 
bit (Code protection off)
#pragma config BOREN = OFF      // Brown-out Reset Enable bit (BOR 
disabled)

#include <stdio.h>
#include <stdlib.h>

/*
 *
 */
int main(int argc, char** argv) {

    unsigned char cnt = 0;

    TRISC = 0; // all output

    while(1) // alle ports klappern
    {

        PORTC = cnt++;
    }

    return (EXIT_SUCCESS);
}

</code>

mfg
Peter

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.