Forum: Mikrocontroller und Digitale Elektronik PIC32EMZ progmmierung


von David (Gast)


Angehängte Dateien:

Lesenswert?

Hey Leute,
Ich habe ein Problem mit meiner Software. Ich glaube auf jeden Fall das 
die Verbindung zum PIC32EMZ1024EFK064 passt, da ich eine Verbindung über 
den ICD3 habe.

Ich habe noch nie PIC programmiert und würde gerne die LED auf der 
Abbildung zum Leuten bringen.

Ich programmiere mit MPLAB v3.50.

Mein derzeitige Source Code mit Configutation Bits lautet:

<c>
//#define _32MZ1024EFK064_

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

// DEVCP0
#pragma config CP = OFF // Code Protect
/*** DEVCFG0 ***/
// The below configuration bits are generated by harmony
// Below confugurations should provide a system clock frequency of 80MHz
#pragma config DEBUG = ON //FF // Background Debugger
#pragma config JTAGEN = OFF //ON // JTAG Port
#pragma config ICESEL = ICS_PGx1 // ICE/ICD Communication Channel
#pragma config TRCEN = OFF //ON // Trace feature in CPU
#pragma config BOOTISA = MIPS32 // MIPS32 or MICROMIPS
#pragma config FECCCON = OFF_UNLOCKED // Dynamic Flash ECC
#pragma config FSLEEP = OFF // Flash Sleep Mode
#pragma config DBGPER = PG_ALL // Allow CPU access to all permission 
regions
#pragma config EJTAGBEN = NORMAL // Normal EJTAG functionality
/*** DEVCFG1 ***/
#pragma config FNOSC = POSC//SPLL // Oscillator Selection Bits
#pragma config DMTINTV = WIN_127_128 // DMT Count Window Interval 
(Window/Interval value is 127/128 counter value)
#pragma config FSOSCEN = OFF //ON // Secondary Oscillator Enable 
(Disable SOSC)
#pragma config IESO = OFF //ON // Internal/External Switch Over 
(Disabled)
#pragma config POSCMOD = HS//EC //OFF // Primary Oscillator 
Configuration (Primary osc disabled)
#pragma config OSCIOFNC = OFF //ON // CLKO Output Signal Active on the 
OSCO Pin (Enabled)
#pragma config FCKSM = CSECME //CSDCMD //// Clock Switching and Monitor 
Selection (Clock Switch Disabled, FSCM Disabled)
#pragma config WDTPS = PS1048576 // Watchdog Timer Postscaler
#pragma config WDTSPGM = STOP // Watchdog Timer Stop During Flash 
Programming
#pragma config WINDIS = NORMAL // Watchdog Timer Window Mode (Watchdog 
Timer is in non-Window mode)
#pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT Disabled)
#pragma config FWDTWINSZ = WINSZ_25 // Watchdog Timer Window Size 
(Window size is 25%)
#pragma config DMTCNT = DMT31
#pragma config FDMTEN = OFF // Deadman Timer Enable (Deadman Timer is 
disabled)
/*** DEVCFG2 ***/
#pragma config FPLLIDIV = DIV_4 //DIV_1 // System PLL Input Divider (1x 
Divider)
#pragma config FPLLRNG = RANGE_13_26_MHZ // System PLL Input Range (5-10 
MHz Input)
//#pragma config FPLLICLK = PLL_POSC //PLL_FRC // System PLL Input Clock 
Selection (POSC is input to the System PLL)
//#pragma config FPLLMULT = MUL_50 //MUL_80 // System PLL Multiplier 
(PLL Multiply by 50)
//#pragma config FPLLODIV = DIV_2 //DIV_8
//#pragma config UPLLFSEL = FREQ_24MHZ // USB PLL Input Frequency 
Selection
//#pragma config UPLLEN = ON // USB PLL Enable
/*** DEVCFG3 ***/
#pragma config USERID = 0x1234u
#pragma config FMIIEN = OFF // Ethernet RMII/MII Enable (MII Enabled)
#pragma config FETHIO = OFF // Ethernet I/O Pin Select (Default Ethernet 
I/O)
#pragma config PGL1WAY = ON // Permission Group Lock One Way 
Configuration (Allow only one reconfiguration)
#pragma config PMDL1WAY = ON // Peripheral Module Disable Configuration 
(Allow only one reconfiguration)
#pragma config IOL1WAY = ON // Peripheral Pin Select Configuration 
(Allow only one reconfiguration)
#pragma config FUSBIDIO = ON // USB USBID Selection (Controlled by Port 
Function)
/*** BF1SEQ0 ***/
#pragma config TSEQ = 0xffff
#pragma config CSEQ = 0xffff
#define FOSC 19200000L
#define SYSFREQ 19200000L
#define PBCLK2 (SYSFREQ/4)

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


    TRISBbits.TRISB8 = 0;
    LATBbits.LATB8 = 1;         /*  writing 1 to this PINB0     */


    //GerneralDelay(0xFFFFF);

    while(1){



    }

    return (EXIT_SUCCESS);
}
</c>

Danke Leute für eure Hilfe.

LG David

von Jobst M. (jobstens-de)


Lesenswert?

David schrieb:
> Ich programmiere mit MPLAB v3.50.

MPLAB oder MPLABX?



Bei mir läuft folgende Konfig auf einem PIC32MZ2048EFM:
1
/*** DEVCFG0 ***/
2
3
#pragma config DEBUG =      ON    // Zumindest in der Programmierphase - sonst OFF
4
#pragma config JTAGEN =     OFF    // JTAG wird nicht verwendet
5
#pragma config ICESEL =     ICS_PGx2  // Dort hängt der ICSP vom Pickit3 dran
6
#pragma config TRCEN =      ON    // Zumindest in der Programmierphase - sonst OFF
7
#pragma config BOOTISA =    MIPS32  // Großer Code (Alt.: MICROMIPS)
8
#pragma config FECCCON =    OFF_UNLOCKED // Speicherconfig
9
#pragma config FSLEEP =     OFF    // Flash sleep-Mode
10
#pragma config DBGPER =     PG_ALL  // Darf bei Debug überall zugreifen (Permissiongroup)
11
#pragma config EJTAGBEN =   NORMAL  // Extendet JTAG
12
#pragma config CP =         OFF    // CopyProtection - im Moment nicht ...
13
14
/*** DEVCFG1 ***/
15
16
#pragma config FNOSC =      SPLL  // Sysclockselection
17
#pragma config DMTINTV =    WIN_127_128  // Deadman
18
#pragma config FSOSCEN =    OFF    // Sec. Osc aus
19
#pragma config IESO =       OFF    // Clockswitching aus
20
#pragma config POSCMOD =    EC    // Für External Clock. Bei FRC auch OFF
21
#pragma config OSCIOFNC =   ON    // Gibt clock wieder aus (extern)
22
#pragma config FCKSM =      CSDCME  // Clockswitching: Disable ; Fail-Safe-Clock-Monitor: Enable
23
#pragma config WDTPS =      PS1048576  // Watchdog
24
#pragma config WDTSPGM =    STOP  // Watchdog
25
#pragma config FWDTEN =     OFF    // Watchdog aus
26
#pragma config WINDIS =     NORMAL  // Watchdog
27
#pragma config FWDTWINSZ =  WINSZ_25  // Watchdog
28
#pragma config DMTCNT =     DMT31  // Deadman
29
#pragma config FDMTEN =     OFF    // Deadman aus
30
31
/*** DEVCFG2 ***/
32
33
#pragma config FPLLIDIV =   DIV_3  // 24MHz POSC / 3 = 8 MHz ; Sonst 8MHz FRC / 1 = 8 MHz
34
#pragma config FPLLRNG =    RANGE_5_10_MHZ  // 8 MHz
35
#pragma config FPLLICLK =   PLL_POSC  // Externer Clock (POSC = 24MHz) als Referenz für PLL ; Sonst 8MHz FRC: PLL_FRC
36
#pragma config FPLLMULT =   MUL_50  // PLL multipliziert mit 50 (Fout dort 350-700MHz) ergibt 400MHz
37
#pragma config FPLLODIV =   DIV_2  // Sysclk = Fout durch 2
38
#pragma config UPLLFSEL =   FREQ_24MHZ  // POSC hat 24MHz für USB (derzeit unused)
39
// #pragma config UPLLEN =     OFF  // Kennt dieser Controller nicht
40
41
/*** DEVCFG3 ***/
42
43
#pragma config USERID =     0xffff  // ID für JTAG / ICSP
44
#pragma config FMIIEN =     OFF    // Ethernet
45
#pragma config FETHIO =     OFF    // On = Default I/O-Pins Off = Alternative I/O Pins für Ethernet
46
#pragma config PGL1WAY =    OFF    // Allow Reconfig
47
#pragma config PMDL1WAY =   OFF    // Allow Reconfig
48
#pragma config IOL1WAY =    OFF    // Allow Reconfig
49
#pragma config FUSBIDIO =   OFF    // USB-Pins sind Port


David schrieb:
> Ich habe noch nie PIC programmiert und würde gerne die LED auf der
> Abbildung zum Leuten bringen.

Klingeln tun die eigentlich nie ... ;-)



Gruß

Jobst

von Tobi (Gast)


Lesenswert?

Hallo,
du musst auf jeden Fall noch den Pin von analog auf digital schalten
-> (ADPCFG Register für AN48 auf 1)
und eventuell noch den Parallel Master Port deaktivieren :)
-> (_PMPEN=0;)

Grüße

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.