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.
> TRISBbits.TRISB10 = 0; // als output setzen > TRISBbits.TRISB11 = 0; // als output setzen Das passt. > _RB10 = 0; > _RB11 = 1; Schreib mal: LATBbits.LATB10 = 0; LATBbits.LATB11 = 1; Funktionierts dann?
habe mit LATBs auch probiert... geht auch nicht. Habe so ein Verdacht das das Kontroller gar nicht funzt. Kann das irgenwie anders testen, ob das Kontroller das Programm annimmt?
Äh, ja. Hast du mal ein Verify gemacht? Ich bin davon ausgegangen dass das Programm drin ist. Der ICD meckert wenns nicht geklappt hat.
Ja ICD2 sagt das alles OK ist. Habe schon mehrmals programmiert und geprüft mit ICD2.
Oh, hab grad was gesehen: Schreib mal am Ende deiner Main: while(1);
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 }
Jetzt haste dein Tris ja nicht mehr umgeschaltet??? Schreib das mal so:
1 | _CONFIG1(FWDTEN_OFF & BKBUG_ON & ICS_PGx1 & GWRP_OFF) |
2 | _CONFIG2(FNOSC_FRC & GCP_OFF) |
3 | |
4 | int main () |
5 | {
|
6 | TRISBbits.LATB10 = 0; |
7 | TRISBbits.LATB11 = 0; |
8 | |
9 | LATBbits.LATB10 = 1; |
10 | LATBbits.LATB11 = 0; |
11 | |
12 | while(1); |
13 | }
|
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. ------------------------------------------------------------------------ -----
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 | }
|
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
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
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.