Jump to content
ELFORUM - Forumul electronistilor
Guest sorinpetrila

Ajutor incepator 16f690 (pickit 2)

Recommended Posts

Guest sorinpetrila

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 to comment
Share on other sites

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 to comment
Share on other sites

Guest sorinpetrila

Raspuns corect

Cat de idiot pot fi. Na, adevarul e ca abia m-am apucat dar tot idiot ma numesc.

Merci mult.

Link to comment
Share on other sites

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 to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines