da
lostsheep » 13 ott 2014, 18:32
Scusate ma non getto la spugna facilmente.
Mi son messo a fare delle ricerche in rete e ho trovato questo post in cui viene trattato un problema analogo al mio: il circuito funziona solo se viene lasciato connesso il programmatore.
A quanto pare per lui era un problema di settaggio nei fuses. Nel mio programma li ho impostati come segue:
- Codice: Seleziona tutto
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is MCLR)
#pragma config BOREN = OFF // Brown-out Detect Enable bit (BOD disabled)
#pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EE Memory Code Protection bit (Data memory code protection off)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
#define _XTAL_FREQ 4000000 // Defining this macro let the compiler to compute the correct number of instructions in the __delay_ms function
e, nella funzione di init,
- Codice: Seleziona tutto
TRISA = 0xff;
TRISB = 0xc0;
CMCON = 0x07;
uso PORTA come input - qui ho i pulsanti, PORTB come input per i pin <7:6> e come output <5:0> - qui ho i led e spengo il comparatore analogico per utilizzare PORTA come input digitali.
Ho commesso qualche errore? Ricordo che il PIC in questione è un 16F628A.