Sari la conținut
ELFORUM - Forumul electronistilor

Flasher cu PIC16F628A


lama

Postări Recomandate

Salut. Am o problema tare ciudata. Fie pu pic16f628a, cu MCLS pus la + prin 10k si o rezistenta de 1k si un led legate la RA7 (iar celalalt capat la masa).Fie codul de mai jos(care nu merge)Aveti idee de ce?/************************************************************************* ** Processor: 16F628a ** Pin assignments: ** RA7 - indicator LED ** RA6 - Buzzer ** RA1 - DQ la DS18B20 ** RB0 - RS ** RB1 - EN ** RB2-5 - D4-7 LCD ** RA2 - button pe pin pus la Vdd prin 10k ** RA3 - button pe pin pus la Vdd prin 10k ** RA4 - button pe pin pus la Vdd prin 10k *************************************************************************/#include #define _XTAL_FREQ 4000000 // oscillator frequency for _delay() /***** CONFIGURATION *****///FOSC_INTOSCIO I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN//WDTE_OFF Watchdog Timer Enable OFF//PWRTE_ON Power-up Timer Enable ON//LVP_OFF Low-Voltage Programming Enable ON//BOREN_OFF Brown-out Detect Enabl OFF//CPD_OFF Data EE Memory Code Protection OFF//CP_OFF Flash Program Memory Code Protection OFF//MCLRE_OFF RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD__CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_ON & LVP_OFF & BOREN_OFF & CPD_OFF & CP_OFF & MCLRE_OFF);/************************************************************** Main Program**************************************************************/void main(void){ TRISB = 0x00; // portB is output; TRISA = 0x00; CMCON = 0b00000111; // disable comparators PORTB = 0x00; // all low PORTA = 0x00;while(1){ //looping//RA7=1;__delay_ms(2000);RA7=0;PORTA=1;__delay_ms(2000);PORTA=0; } //loping} //main

Link spre comentariu
  • Răspunsuri 19
  • Creat
  • Ultimul Răspuns

Top autori în acest subiect

  • Liviu M

    8

  • lama

    8

  • MatyC

    3

  • sosoi

    1

Zile populare

Top autori în acest subiect

Ce versiunede compilator ai (stiu ca e picc de la HiTech, ma intereseaza releasul)?

Ca eu am 9.80 si ce e la mine in pic16f62xa.h difera de ce ai folosit tu in cod (in directiva __CONFIG)

// Oscillator configurations #define RCCLK		0x3FFF#define RCIO		0x3FFE#define INTCLK		0x3FFD#define INTIO		0x3FFC#define EC		0x3FEF#define HS		0x3FEE#define XT		0x3FED#define LP		0x3FEC
Cu alte cuvinte, ca sa folosesti RA6&RA/ ca I/O iti trebuie INTIO (daca ai avea acelasi compilator ca mine).
Link spre comentariu

Ce versiunede compilator ai (stiu ca e picc de la HiTech, ma intereseaza releasul)?Ca eu am 9.80 si ce e la mine in pic16f62xa.h difera de ce ai folosit tu in cod (in directiva __CONFIG)

// Oscillator configurations #define RCCLK		0x3FFF#define RCIO		0x3FFE#define INTCLK		0x3FFD#define INTIO		0x3FFC#define EC		0x3FEF#define HS		0x3FEE#define XT		0x3FED#define LP		0x3FEC
Cu alte cuvinte, ca sa folosesti RA6&RA/ ca I/O iti trebuie INTIO (daca ai avea acelasi compilator ca mine).
vers 9.83si are un heder separat ptr 628a.care arata c-am asa// Config Register: CONFIG#define CONFIG 0x2007// Oscillator Selection bits// RC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, Resistor and Capacitor on RA7/OSC1/CLKIN#define FOSC_EXTRCCLK 0xFFFF// RC oscillator: I/O function on RA6/OSC2/CLKOUT pin, Resistor and Capacitor on RA7/OSC1/CLKIN#define FOSC_EXTRCIO 0xFFFE// INTOSC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN#define FOSC_INTOSCCLK 0xFFFD// INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN#define FOSC_INTOSCIO 0xFFFC// EC: I/O function on RA6/OSC2/CLKOUT pin, CLKIN on RA7/OSC1/CLKIN#define FOSC_ECIO 0xFFEF// HS oscillator: High-speed crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN#define FOSC_HS 0xFFEE// XT oscillator: Crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN#define FOSC_XT 0xFFED// LP oscillator: Low-power crystal on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN#define FOSC_LP 0xFFEC// Watchdog Timer Enable bit// WDT enabled#define WDTE_ON 0xFFFF// WDT disabled#define WDTE_OFF 0xFFFB// Power-up Timer Enable bit// PWRT disabled#define PWRTE_OFF 0xFFFF// PWRT enabled#define PWRTE_ON 0xFFF7// RA5/MCLR/VPP Pin Function Select bit// RA5/MCLR/VPP pin function is MCLR#define MCLRE_ON 0xFFFF// RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD#define MCLRE_OFF 0xFFDF// Brown-out Detect Enable bit// BOD enabled#define BOREN_ON 0xFFFF// BOD disabled#define BOREN_OFF 0xFFBF// Low-Voltage Programming Enable bit// RB4/PGM pin has PGM function, low-voltage programming enabled#define LVP_ON 0xFFFF// RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming#define LVP_OFF 0xFF7F// Data EE Memory Code Protection bit// Data memory code protection off#define CPD_OFF 0xFFFF// Data memory code-protected#define CPD_ON 0xFEFF// Flash Program Memory Code Protection bit// Code protection off#define CP_OFF 0xFFFF// 0000h to 07FFh code-protected#define CP_ON 0xDFFF
Link spre comentariu

Ai dreptate, le-au modificat.

Eu nu prea mai am idei. Eventual sa activezi si PERTE.

 

bit 3: PWRTE: Power-up Timer Enable bit (1)

1 = PWRT disabled

0 = PWRT enabled

@MatyC : n-are ADC.

 

LE Daca poi optiunea aia cu OSC iti scoate clockul pe pini si chiar nu-i mai poti folosi.

Link spre comentariu

Nu mai inteleg nimicAm incarcat in PIC un cod mai vechi care foloseste acest minunat pin RA7 (un 5 led chaser)Si culmea ca merge.Singura deosebire e in configurare, unde are PWRTE_ONUPDATE: e identic si hex-ul incarcat aprinde RA7

Link spre comentariu

Am modificat codul din 5 led chaser (mai jos) si merge. DAR nu ma prind de ce./************************************************************************* ** Processor: 16F628 ** *************************************************************************** ** Pin assignments: ** RA6 - indicator LED ** RA7 - indicator LED ** RB3 - indicator LED ** RB4 - indicator LED ** RB5 - indicator LED ** GP4 - indicator LED sau RS232 ** RB0 - Legat la RA2 DUMMY ptr RB0 ** RB1 - Legat la RA3 DUMMY ptr RB1 ** RA0,1,2,3,4 - Touch PAD *************************************************************************/#include __CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_ON & LVP_OFF & BOREN_OFF & CPD_OFF & CP_OFF & MCLRE_OFF);#define _XTAL_FREQ 4000000 /* Crystal frequency in MHz */#define cit_delay 200void main(void){unsigned char sPORTA, sPORTB; // port D init TRISB = 0x00; // portB is output; TRISA = 0x00; CMCON = 0b00000111; // disable comparators PORTB = 0x00; // all low PORTA = 0x00; while(1){ RA7=1; __delay_ms(cit_delay); RA7=0; __delay_ms(cit_delay); }}

Link spre comentariu

Mi-a ramas pe creier ADCON asta mai de demult. Liviu M ai dreptate ca la primul cod prezentat nu are delay la tranzitia din 0 in 1. Corect ar fi trebuit:

while(1){            //loopin   //RA7=1;__delay_ms(2000);RA7=0;   PORTA=1;__delay_ms(2000);PORTA=0;__delay_ms(2000);} //loping
in ciuda faptului ca are efect asupra intregului port A. Nu cumva trebuie RA7?
Link spre comentariu

Creează un cont sau autentifică-te pentru a adăuga comentariu

Trebuie să fi un membru pentru a putea lăsa un comentariu.

Creează un cont

Înregistrează-te pentru un nou cont în comunitatea nostră. Este simplu!

Înregistrează un nou cont

Autentificare

Ai deja un cont? Autentifică-te aici.

Autentifică-te acum



×
×
  • Creează nouă...

Informații Importante

Am plasat cookie-uri pe dispozitivul tău pentru a îmbunătății navigarea pe acest site. Poți modifica setările cookie, altfel considerăm că ești de acord să continui.Termeni de Utilizare si Ghidări