pic24F xxxx port initialisieren

OP #679456
Lesenswert?

Hallo an alle,

bin schon seit 2 Tagen mit dem genannten PIC beschäftigt.
Kann nicht einmal einen PortB ein-/ausschalten. Ich benutze MPLAB7.60a 
und ICD2 zum programmieren.

So wird initialisiert:

_CONFIG1(FWDTEN_OFF & BKBUG_ON & ICS_PGx1 & GWRP_OFF)
_CONFIG2(FNOSC_FRC & GCP_OFF)

int main(void)
{

// I/O-Ports freischalten...

  TRISBbits.TRISB10 = 0;  // als output setzen
  TRISBbits.TRISB11 = 0;  // als output setzen

  _RB10 = 0;
  _RB11 = 1;
}

bin für jede Hilfe dankbar.
OP #679559
Lesenswert?

Habe mit while(1) so ausprobiert, immer noch nichts zu messen...

_CONFIG1(FWDTEN_OFF & BKBUG_ON & ICS_PGx1 & GWRP_OFF)
_CONFIG2(FNOSC_FRC & GCP_OFF)
void(main){
  while(1) {

  LATBbits.LATB10 = 0;
  LATBbits.LATB11 = 1;

  int x = 65535;
  while(x){
    x--;
  }
  LATBbits.LATB10 = 1;
  LATBbits.LATB11 = 0;

  int y = 65535;
  while(y){
    y--;
  }

  } //while-schleife
}
Gast #679733
Lesenswert?

Hi,

versuche es mal mit:
1
AD1PCFG = 0xffff;
gleich nach der Initialisierung (LAT und TRIS).

------------------------------------------------------------------------ 
-----
Note: In order to use pins multiplexed with the A/D for digital I/O, the 
corresponding bits in the AD1PCFG register must be set to ‘1’, even if 
the A/D module is turned off.
------------------------------------------------------------------------ 
-----
OP #679971
Lesenswert?

Das habe ich auch drin. (AD1PCFG = 0xffff;)
Versorgung:3,3V
DISVREG am Masse;
ein C zwischen Vddcore und Masse;

Ich habe keine Ahnung was noch alles sein kann. Habe davor sehr viel mit 
pic16f-serie gemacht, und auch bei dsPIC30xxxx pwm-modul in lauf 
gekriegt. Und jetzt stehe ich wie blöd vor dem einfachen 
Portinitialisierung...
Hier noch mal die Code:
1
_CONFIG1(FWDTEN_OFF & BKBUG_ON & ICS_PGx1 & GWRP_OFF)
2
_CONFIG2(FNOSC_FRC & GCP_OFF)
3

4
void(main){
5

6
TRISBbits.TRISB10 = 0;  // als output setzen
7
TRISBbits.TRISB11 = 0;  // als output setzen
8
AD1PCFG=0xffff;
9

10
  while(1) {
11
  LATBbits.LATB10 = 0;
12
  LATBbits.LATB11 = 1;
13

14
  int x = 65535;
15
  while(x){
16
    x--;
17
  }
18
  LATBbits.LATB10 = 1;
19
  LATBbits.LATB11 = 0;
20

21
  int y = 65535;
22
  while(y){
23
    y--;
24
  }
25

26
  } //while-schleife
27
}
Gast #717497
Lesenswert?

Wahrscheinlich liegt das Problem an Bit 6 vom OSCCON Register.
Dieses Bit verhindert Änderungen der I/O Configuration.

Dieser Code hat bei mir funktioniert:

;*********************************************************************** 
*******


.include "p24FJ48GA002.inc"
config __CONFIG1, JTAGEN_OFF & GCP_OFF & GWRP_OFF & BKBUG_OFF & COE_OFF 
& ICS_PGx1 & FWDTEN_OFF & WINDIS_OFF & FWPSA_PR32 & WDTPS_PS1
config __CONFIG2, IESO_ON & FNOSC_PRIPLL & FCKSM_CSDCMD & OSCIOFNC_OFF & 
IOL1WAY_OFF & I2C1SEL_PRI & POSCMOD_XT


.global __reset
__reset:
        nop

Start:
        bclr    OSCCON,#6           ; Unlock Config Protection
        mov     #0xFBFF,W0          ; Configue Pin 21 as Output
        mov     W0,TRISB

L1:     bset    LATB,#10            ; turn on red LED
        goto    L1

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren