Vizitator sorinpetrila Postat August 8, 2010 Partajează Postat August 8, 2010 Incerc sa modific un mic program din pickit2 lessons dar fara succes. Poate cineva sa imi dea un raspuns viabil? Programul face un led sa se aprinda alternativ. Eu am incercat sa maresc perioada de aprins si stins. Programul original: #include <p16F690.inc> __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF) cblock 0x20Delay1 ; Define two file registers for theDelay2 ; delay loop endc org 0Start: bsf STATUS,RP0 ; select Register Page 1 bcf TRISC,0 ; make IO Pin B.0 an output bcf STATUS,RP0 ; back to Register Page 0MainLoop: bsf PORTC,0 ; turn on LED C0OndelayLoop: decfsz Delay1,f ; Waste time. goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec. ; call it a two-tenths of a second. bcf PORTC,0 ; Turn off LED C0OffDelayLoop: decfsz Delay1,f ; same delay as above goto OffDelayLoop decfsz Delay2,f goto OffDelayLoop goto MainLoop ; Do it again... end Program modificat: #include <p16F690.inc> __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF) cblock 0x20Delay1 ; Define two file registers for theDelay2 ; delay loopDelay3 endc org 0Start: bsf STATUS,RP0 ; select Register Page 1 bcf TRISC,0 ; make IO Pin B.0 an output bcf STATUS,RP0 ; back to Register Page 0MainLoop: bsf PORTC,0 ; turn on LED C0OndelayLoop: decfsz Delay1,f ; Waste time. goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec. decfsz Delay3,f ; call it a two-tenths of a second. goto OndelayLoop bcf PORTC,0 ; Turn off LED C0OffDelayLoop: decfsz Delay1,f ; same delay as above goto OffDelayLoop decfsz Delay2,f goto OffDelayLoop decfsz Delay3,f goto OffDelayLoop goto MainLoop ; Do it again... end Va multumesc. Link spre comentariu
Eugen_B Postat August 8, 2010 Partajează Postat August 8, 2010 Nu ma pricep deloc la assembly , dar din cate inteleg eu ca face programul , i-ai mai pus un loop de 256 de ori pentru fiecare delay , deci o sa clipeasca la aproximativ 50 secunde , ai asteptat atata sa vezi daca merge ? . Presupun ca ai putea sa incarci valoarea lui delay3 cu 10 , inainte de loop astfel sa ai 2 secunde delay (0.197*10 = 2 sec). Link spre comentariu
Vizitator sorinpetrila Postat August 8, 2010 Partajează Postat August 8, 2010 Raspuns corect Cat de idiot pot fi. Na, adevarul e ca abia m-am apucat dar tot idiot ma numesc. Merci mult. Link spre comentariu
ducu Postat August 20, 2010 Partajează Postat August 20, 2010 Salut, daca tot esti la inceput iti recomand MikroC, este usor de invatat si usor de inteles. Mai jos ai un exemplu de cod care face un led sa clipeasca, programul este mult mai mic si mult mai usor de asimilat. Here is the C program written for MikroC PRO for PIC 2009 (version v3.8)./*'*******************************************************************************' Lesson nr.02:' Blink a LED (Blink entire PORTB)' Written by:' Aureliu Raducu Macovei, 2010.' Description:' In this experiment we will show how to set MCU to make a LED blinking.' PORTB and 1 LED will be used to show that.' Test configuration:' MCU: PIC16F628A' Test.Board: WB-106 Breadboard 2420 dots' Configuration Word' Oscillator: INTOSC:I/O on RA.6, I/O on RA.7' Watchdog Timer: OFF' Power up Timer: Disabled' Master Clear Enable: Enabled' Browun Out Detect: Enabled' Low Voltage Program: Disabled' Data EE Read Protect: Disabled' Code Protect: OFF'********************************************************************************/void main() //MAIN;{ TRISB = 0x00; //SET PORTB TO BE OUTPUT; PORTB = 0x00; //TURN OFF LEDs ON PORTB; while(1){ //INFINITE LOOP; PORTB = ~PORTB; //INVERT STATE ON PORTB; Delay_ms(1000); //WAIT 1S; <<aici setezi timpul cat doresti tu in "ms" }} //END; Link spre comentariu
Vizitator sorinpetrila Postat August 22, 2010 Partajează Postat August 22, 2010 merci mult. continui cu asamblor apoi continui cu altceva. merci inca odata Link spre comentariu
Postări Recomandate
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 contAutentificare
Ai deja un cont? Autentifică-te aici.
Autentifică-te acum