Autor Tema: Por favor ayuda...  (Leído 2091 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado sQs

  • PIC10
  • *
  • Mensajes: 47
Por favor ayuda...
« en: 31 de Mayo de 2011, 17:41:48 »
Les pido por favor alguien que domine bien el ASM me pueda ayudar haciendo una pequeña rutina para el PIC 12F683, le estare muy agradecido en verdad.
Lo que necesito que aga y no lo e conseguido es lo siguiente:

- Configurar el puerto GP4 estara como salida unicamente.
- Configurar el puerto GP1 estara como entrada, posteriormente necesitare cambiarlo a salida.
- Que se aga una comparacion si GP4 activo (prendido).
- En caso de estarlo se haria otra comparacion: si esta recibiendo alguna señal el puerto GP1 (en realidad es cuando se presione un boton que estara conectado a este puerto).
- Y en caso que si este presionado el boton (puerto GP1), que aga una demora (por ejemplo 500 ms, esta yo la estare variando por medio de una variable)
- Y ahora necesitare que el mismo puerto GP1 se cambie como salida y envie una señal por el mismo GP1 (digamos como un parpadeo muy rapido).

Les suplico un poco de ayuda ya que e encontrado mucho material en el foro pero todo es para pics 16 o 18 y los escasos que encuentro para 12F*** estan en lenguaje basic o C, la verdad que siento que pudiera hacerlo en en estos lenguajes solo que el proyecto este es largo y yo lo estoy editando a mis necesidades, espero su amable ayuda, gracias.

Desconectado rivale

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1707
Re: Por favor ayuda...
« Respuesta #1 en: 31 de Mayo de 2011, 17:45:40 »
que es lo que llevas hecho hasta ahora, sube tu codigo y te ayudo
"Nada es imposible, no si puedes imaginarlo"

Desconectado sQs

  • PIC10
  • *
  • Mensajes: 47
Re: Por favor ayuda...
« Respuesta #2 en: 31 de Mayo de 2011, 18:18:55 »
Gracias, el codigo es muy largo pero aqui voy a poner algo, por lo menos el encabezado donde van las variables, una interrupcion que tengo, la parte del main para que veas como entan declaradas algunas entradas o salidas y la parte donde trato de hacer el bucle que este preguntando lo que les pregunto, que de hecho primeramente no lo hice como bucle solo trate de hacer que al presionar un boton enviara algo asi como un destello rapido por el puerto GP1, hiciera una demora y luego volviera a enviar un destello rapido, haber si puedes verlo eso esta al final de este codigo.

Código: ASM
  1. list      p=12F683        ; list directive to define processor
  2.         #include <p12F683.inc>    ; processor specific variable definitions
  3.  
  4.         errorlevel  -302          ; suppress message 302 from list file
  5.  
  6.         __CONFIG   _FCMEN_OFF & _IESO_OFF & _CP_ON & _CPD_ON & _BOD_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTOSCIO
  7.  
  8. ;***** VARIABLE DEFINITIONS******************
  9. w_temp        EQU     0x70        ; variable used for context saving
  10. status_temp   EQU     0x71        ; variable used for context saving
  11.  
  12. FLAGS           EQU             0x20            ;software state register
  13. PULSER          EQU             0x21            ;pulse on counter
  14. DWELLTIMER      EQU             0x22            ;pulse off counter
  15. STATE           EQU             0x23            ;programmed state
  16. BUTTONHOLD      EQU             0x24
  17. FREQR           EQU             0x25            ;frequency value
  18. TEMP1           EQU             0x26
  19. TEMP2           EQU             0x27
  20. PULSEL          EQU             0x28
  21. DWELLTIMEL      EQU             0x29
  22. TEMP5           EQU             0x2A
  23. LEDBLINK        EQU             0x2B
  24. TEMP3           EQU             0x2C
  25.  
  26.  
  27. BURSTRATE       EQU             0x63 ;3E
  28. BURSTRight      EQU             0x64 ;3F
  29. BURSTLeft       EQU             0x65
  30. FLAGS2          equ             0x66 ;41
  31. SHADOWP         equ             0x67 ;42
  32.  
  33.  
  34. LEDActivado             equ             0x68 ;43
  35. DATOSEE                 equ             0x69 ;44
  36. DIRECCIONEE             equ             0x6A ;45
  37. DESACTIVADO     equ             0x6B ;46
  38. TEMPFREE                equ             0x6C ;47
  39. TEMPLED3EE              equ             0x6D ;48
  40. TEMPLED3EEconta equ             0x6E ;49
  41. TEMPLED4EE              equ             0x6F ;4A
  42. TEMPLED4EEconta equ             0x72 ;4B
  43. HAYCAMBIO               equ             0x73 ;4C
  44. TEMP                    equ             0x74 ;4D
  45. TEMPFastForward equ             0x75
  46. TEMPFastRewind  equ             0x76
  47. TEMPFast                equ             0x77
  48.  
  49.  
  50.  
  51. ;*******bits in FLAGS register***********
  52. PULSEONR                equ             0
  53. PULSEONL                equ             1
  54. TRIGOUT                 equ             2
  55. LEDHI                   equ             3
  56. STATECHANGE             equ             4
  57. BURSTACTIVE             equ             6
  58. COD5MODE                equ             7
  59.  
  60. ;******bits in FLAGS2 register
  61. BDWELLRT        equ             0
  62. BDWELLLT        equ             1
  63. BURSTONR        equ             2
  64. BURSTONL        equ             3
  65.  
  66.  
  67. ActLEDIzq       equ             1
  68. ActLEDDer       equ             0
  69.  
  70.  
  71. ;*******bits in STATE register***********
  72. RIGHTACTIVE             equ             0
  73. LEFTACTIVE              equ             1
  74.  
  75. ;*********GPIO pin names*****************
  76. LEDL                    equ             4
  77. LEDR                    equ             5
  78. BUTTONR                 equ             2
  79. BUTTONL                 equ             3
  80. TRIGGERR                equ             0
  81. TRIGGERL                equ             1
  82.  
  83.  
  84.  
  85.  
  86. ;**********************************************************************
  87.         ORG     0x000             ; processor reset vector
  88.         goto    main              ; go to beginning of program
  89.        
  90.  
  91.         ORG     0x004             ; interrupt vector location
  92.         movwf   w_temp            ; save off current W register contents
  93.         movf    STATUS,w          ; move status register into W register
  94.         movwf   status_temp       ; save off contents of STATUS register
  95.  
  96.                         ;Take a good note here. OSC is left at default 4MHz.
  97.                         ; We are running at 1MHz instruction cycle, or 1 micro second
  98.                         ;Timer 2 is prescaled 1:4 and compared (PR2) to 250.
  99.                         ; we now have hardware interupt that falls every 1ms exactly
  100.                         ;within limitation of osctune. Main code is inconsequential.
  101.                         ;PULSE and DWELL values control the signals precisely.
  102.                         ;All pulse logic is switched within the few microseconds to
  103.                         ;service the interupt routine. DO NOT modify the ISR
  104.                         ;with any kind of 'wait' or 'loop'. If you want to trigger
  105.                         ; timed events do so by setting an open FLAG bit and have the
  106.                         ;event done in the main loop.
  107.  
  108.  
  109.         btfss   PIR1, TMR2IF            ;timer 2 int happened
  110.         retfie
  111.  
  112. ;**************** Interruptions *********************************************
  113.                                                                 ;Our main routine will turn the flag bit
  114.                                                                 ;LEDON on or off. The 10ms pulse is a duty cycle
  115.                                                                 ;for the code to work with both CG and
  116.                                                                 ;matrix controllers.
  117.  
  118. ;**************** Tactiles push logic **************************************
  119.  
  120. BlinkLed       
  121.         btfss   FLAGS, LEDHI
  122.         goto    LedLow
  123.         decfsz  LEDBLINK, f                     ;if pulse is active, count down 10ms
  124.         goto    RightLED
  125.         movlw   0x0A
  126.         movwf   LEDBLINK
  127.         bcf             FLAGS, LEDHI            ;10ms done, turn off LEDHI bit
  128.         goto    RightLED
  129. LedLow
  130.         decfsz  LEDBLINK, f                     ;LEDLO time, count down 10ms
  131.         goto    RightLED
  132.         movlw   0x0A
  133.         movwf   LEDBLINK
  134.         bsf             FLAGS, LEDHI            ;10ms done, turn LEDHI bit on
  135.  
  136. RightLED
  137.         btfsc   STATE, RIGHTACTIVE      ;is RF on?
  138.         goto    OutputRightLED
  139.         bsf             STATUS, RP0                     ;bank 1
  140.         bsf             TRISIO, LEDR            ;tristate LED
  141.         bcf             STATUS, RP0                     ;bank 0
  142.         goto    LeftLED
  143. OutputRightLED
  144.         btfsc   FLAGS, LEDHI            ;if ledhi true,
  145.         bsf             GPIO, LEDR                      ;turn output hi
  146.         btfss   FLAGS, LEDHI            ;if ledhi flase,
  147.         bcf             GPIO, LEDR                      ;turn led output lo
  148.         bsf             STATUS, RP0                     ;bank 1
  149.         bcf             TRISIO, LEDR            ;turn output on
  150.         bcf             STATUS, RP0                     ;bank 0
  151.  
  152. LeftLED
  153.         btfsc   STATE, LEFTACTIVE       ;is RF on?
  154.         goto    OutputleftLED
  155.         bsf             STATUS, RP0                     ;bank 1
  156.         bsf             TRISIO, LEDL            ;tristate LED
  157.         bcf             STATUS, RP0                     ;bank 0
  158.         goto    RightTrigger
  159. OutputleftLED
  160.         btfsc   FLAGS, LEDHI            ;if ledhi true,
  161.         bsf             GPIO, LEDL                      ;turn output hi
  162.         btfss   FLAGS, LEDHI            ;if ledhi flase,
  163.         bcf             GPIO, LEDL                      ;turn led output lo
  164.         bsf             STATUS, RP0                     ;bank 1
  165.         bcf             TRISIO, LEDL            ;turn output on
  166.         bcf             STATUS, RP0                     ;bank 0
  167.  
  168.  
  169. ;**************** Right trigger logic***************************************   
  170. RightTrigger
  171. ;**************** Disparar en modo programacion
  172.         btfsc   DESACTIVADO, 1
  173.         goto    ActiveR
  174. ;**********************************************
  175.         btfsc   STATE, RIGHTACTIVE      ;is RF on?
  176.         goto    ActiveR
  177.         bsf             STATUS, RP0                     ;bank 1
  178.         bsf             TRISIO, TRIGGERR        ;output off
  179.         bcf             STATUS, RP0                     ;bank 0
  180.         goto    EndInterupt
  181.  
  182. ActiveR
  183.         btfss   FLAGS, TRIGOUT          ;controllertype
  184.         bcf             GPIO, TRIGGERR          ;determines
  185.         btfsc   FLAGS, TRIGOUT          ;output state
  186.         bsf             GPIO, TRIGGERR 
  187.  
  188.         btfsc   FLAGS, BURSTACTIVE
  189.         goto    BurstfireR
  190.  
  191.         btfss   FLAGS, PULSEONR         ;is pulse active?
  192.         goto    OffstateR
  193.         decfsz  PULSER, f                       ;if pulse is active, count down 10ms
  194.         goto    EndInterupt
  195.  
  196.         bcf             FLAGS, PULSEONR         ;10ms is over, clear flags and
  197.         bsf             STATUS, RP0                     ;bank 1
  198.         bsf             TRISIO, TRIGGERR        ;tristate output
  199.         bcf             STATUS, RP0                     ;bank 0
  200.         movf    FREQR, w                        ;and reset pulse time.
  201.         movwf   PULSER
  202.  
  203.         btfss   FLAGS, COD5MODE                 ;test COD5 mode
  204.         goto    EndInterupt
  205.         bcf             STATUS, C
  206.         rrf             PULSER, f                       ;25% DUTYCYCLE for COD5 release
  207.  
  208.         goto    EndInterupt
  209.  
  210. OffstateR
  211.         decfsz  DWELLTIMER, f           ;count down dwell time to next pulse
  212.         goto    EndInterupt
  213.         bsf             FLAGS, PULSEONR         ;if dwell is done turn on outputs
  214.         bsf             STATUS, RP0                     ;bank 1
  215.         bcf             TRISIO, TRIGGERR        ;and reset pulse time
  216.         bcf             STATUS, RP0                     ;bank 0
  217.         movf    FREQR, w                        ;from frequency value
  218.         movwf   DWELLTIMER
  219.  
  220.         btfss   FLAGS, COD5MODE                 ;test COD5 mode
  221.         goto    EndInterupt
  222.         bcf             STATUS, C
  223.         rrf             DWELLTIMER, f  
  224.         addwf   DWELLTIMER, f           ;75% dutycycle for pull
  225.  
  226. BurstfireR
  227. ;**************** Disparar en modo programacion
  228.         btfsc   DESACTIVADO, 1
  229.         goto    $+3
  230. ;**********************************************
  231.         btfss   FLAGS2, BURSTONR
  232.         goto    EndInterupt
  233.         btfsc   FLAGS2, BDWELLRT                ;burst fire
  234.         goto    BurstDwellR
  235.         btfss   FLAGS, PULSEONR                 ;is pulse active?
  236.         goto    OffstateR2
  237.         decfsz  PULSER, f                       ;if pulse is active, count down 10ms
  238.         goto    EndInterupt
  239.         bcf             FLAGS, PULSEONR         ;10ms is over, clear flags and output
  240.         bsf             STATUS, RP0             ;bank 1
  241.         bsf             TRISIO, TRIGGERR        ;and reset pulse time.
  242.         bcf             STATUS, RP0             ;bank 0
  243.         movf    FREQR, w
  244.         movwf   PULSER
  245.         btfsc   FLAGS, COD5MODE                 ;test COD5 mode
  246.         rrf             PULSER, f
  247.         decfsz  BURSTRight, f                           ;count down burst shots
  248.         goto    EndInterupt
  249.         movf    BURSTRATE, w                    ;reset counter
  250.         movwf   BURSTRight
  251.         bsf             FLAGS2, BDWELLRT                        ;signal dwell
  252.         movf    FREQR, w
  253.         movwf   DWELLTIMER                              ;reset dwell counter
  254.         btfss   FLAGS, COD5MODE                 ;test COD5 mode
  255.         goto    EndInterupt
  256.         bcf             STATUS, C
  257.         rrf             DWELLTIMER, f
  258.         addwf   DWELLTIMER, f
  259.         goto    EndInterupt
  260.  
  261. OffstateR2
  262.         decfsz  DWELLTIMER, f           ;count down dwell time to next pulse
  263.         goto    EndInterupt
  264.         bsf             FLAGS, PULSEONR         ;if dwell is done turn on outputs
  265.         bsf             STATUS, RP0             ;bank 1
  266.         bcf             TRISIO, TRIGGERR        ;and reset pulse time
  267.         bcf             STATUS, RP0             ;bank 0
  268.         movf    FREQR, w                        ;from frequency value
  269.         movwf   DWELLTIMER
  270.         btfss   FLAGS, COD5MODE                 ;test COD5 mode
  271.         goto    EndInterupt
  272.         bcf             STATUS, C
  273.         rrf             DWELLTIMER, f
  274.         addwf   DWELLTIMER, f
  275.         goto    EndInterupt
  276.  
  277. BurstDwellR
  278.         btfss   FLAGS, TRIGOUT
  279.         goto    CGBurstR
  280.         btfss   GPIO, TRIGGERR
  281.         goto    EndInterupt
  282.         goto    BurstResetR
  283.  
  284. CGBurstR
  285.         btfsc   GPIO, TRIGGERR
  286.         goto    EndInterupt
  287.  
  288. BurstResetR
  289.         bcf             FLAGS, PULSEONR         ;if dwell is done turn on outputs
  290.         bcf             FLAGS2, BDWELLRT
  291.         bcf             FLAGS2, BURSTONR
  292.  
  293.  
  294.  
  295.  
  296. EndInterupt
  297.         bcf             PIR1, TMR2IF
  298.  
  299.         movf    status_temp,w     ; retrieve copy of STATUS register
  300.         movwf   STATUS            ; restore pre-isr STATUS register contents
  301.         swapf   w_temp,f
  302.         swapf   w_temp,w          ; restore pre-isr W register contents
  303.         retfie                      ; return from interrupt
  304.  
  305.  
  306.  
  307. ;
  308. ;              HAY MUCHAS RUTINAS MAS AQUI PERO NO LAS PONGO PORQUE EL PROGRAMA ES LARGO Y NO LO VEO NECESARIO
  309. ;
  310.  
  311.  
  312.  
  313. main
  314.  
  315.         clrf    LEDActivado
  316.         clrf    DATOSEE
  317.         clrf    DIRECCIONEE
  318.         clrf    DESACTIVADO
  319.         clrf    TEMPFREE
  320.         clrf    TEMPLED3EE
  321.         clrf    TEMPLED3EEconta
  322.         clrf    TEMPLED4EE
  323.         clrf    TEMPLED4EEconta
  324.         clrf    HAYCAMBIO
  325.         clrf    TEMP
  326.         clrf    TEMPFastForward
  327.         clrf    TEMPFastRewind
  328.         clrf    TEMPFast
  329. ; --------------------------
  330.  
  331.         clrf    GPIO
  332.         clrf    FLAGS                           ;clear outputs and code status register
  333.         clrf    FLAGS2
  334.         movlw   0x07
  335.         movwf   CMCON0                          ;comparators off
  336.         bsf             STATUS, RP0                     ;bank 1
  337.         movlw   0x0F                            ;start with 0-3 inputs (ADC read)
  338.         movwf   TRISIO                          ;pin 0 & 1 & 5 out, all other inputs
  339.         movlw   0x51                            ;Fosc/16, pin 0 analog
  340.         movwf   ANSEL                           ;Right trigger is analog input
  341.         movlw   0x04
  342.         movwf   WPU                                     ;enable week pullups
  343.         bcf             OPTION_REG, 7           ;enable all week pullups
  344.         bcf             STATUS, RP0                     ;bank 0
  345.  
  346.         movlw   0x01                            ;Left just, Vdd, channel 0
  347.         movwf   ADCON0                          ;module on.
  348.         movlw   0x10
  349.         movwf   TEMP1
  350. Wait4ADC
  351.         decfsz  TEMP1, f
  352.         goto    Wait4ADC                        ;acquisition time
  353.         bsf             ADCON0, 1                       ;start ADC
  354.         btfsc   ADCON0, 1
  355.         goto    $-1                                     ;wait for conversion to be done
  356.         movlw   0x40                            ;about 0.5V from 2V ref
  357.         subwf   ADRESH, w                       ;if f > W, C=1
  358.         btfsc   STATUS, C                       ;ie- if trigger > 0.5V, then matrix
  359.         bsf             FLAGS, TRIGOUT          ;matrix config sources (output high)
  360.         bsf             STATUS, RP0                     ;bank 1
  361.         movlw   0x0C                            ;restore pin IO
  362.         movwf   TRISIO 
  363.         clrf    ANSEL                           ;all digital now
  364.         bcf             STATUS, RP0                     ;bank 0
  365.  
  366.         movlw   0x0A                            ;start with 10ms pulse width
  367.         movwf   LEDBLINK                        ;for the LEDs
  368. ;       movlw   FIRERATE1                       ;this will get overwritten,
  369.         movwf   PULSER                          ; but start with a default value
  370.         movwf   PULSEL
  371.         movwf   DWELLTIMER
  372.         movwf   DWELLTIMEL
  373.         movlw   0x05                            ;init burst rate
  374.         movwf   BURSTRATE
  375.         movwf   BURSTRight
  376.         movwf   BURSTLeft
  377.  
  378. ;       movf    EESTATE, w
  379.         movlw   0x00
  380.         movwf   DIRECCIONEE
  381.         call    ReadEE                          ;get state value
  382.         movwf   STATE
  383.  
  384.  
  385.         movlw   0x01
  386.         movwf   T2CON                           ;timer 2, prescale 1:4, no postscale
  387.         bsf             STATUS, RP0                     ;bank 1
  388.         movlw   0xFA
  389.         movwf   PR2                                     ;setup 1ms hardware interupt
  390.         bsf             PIE1, TMR2IE            ;enable timer2 interupt
  391.         bcf             STATUS, RP0                     ;bank 0
  392.         bsf             T2CON, TMR2ON           ;turn on timer2
  393.         movlw   0xC0
  394.         movwf   INTCON                          ;turn on interupts globally
  395.         goto    InitState                       ;get first fireratSTATE4e value
  396.  
  397.  
  398.  
  399.  
  400. ;******************** Y AHORA EL CODIGO DE LO QUE QUIERO HACER, QUE SE QUE LO ESTOY HACIENDO MAL, PERO NO SE QUE ***********************************************
  401. ;********************************* NO SE SI EL PROBLEMA ESTE EN ALGO RELACIONADO CON LAS INTERRUPCIONES  *******************************************************
  402.         btfss   STATE, LEFTACTIVE       ;is RF on?
  403.         goto    TestLeft
  404.  
  405. ActiveReloaded
  406.         btfss   FLAGS, TRIGOUT          ;controllertype
  407.         bcf             GPIO, TRIGGERL          ;determines
  408.         btfsc   FLAGS, TRIGOUT          ;output state
  409.         bsf             GPIO, TRIGGERL
  410.  
  411.         bcf             FLAGS, PULSEONL         ;10ms is over, clear flags and
  412.         bsf             STATUS, RP0                     ;bank 1
  413.         bsf             GPIO, TRIGGERL  ;tristate output
  414.         bcf             STATUS, RP0                     ;bank 0
  415. ;       call    Wait10ms
  416. ;       bsf             STATUS, RP0                     ;bank 1
  417. ;       bcf             GPIO, TRIGGERL  ;and reset pulse time
  418. ;       bcf             STATUS, RP0                     ;bank 0
  419.  
  420. DemoraActiveReloaded
  421.         movlw   0x64
  422.         movwf   BUTTONHOLD                      ;setup for 2 second hold
  423.         call    Wait10ms
  424.         decfsz  BUTTONHOLD, f          
  425.         goto    DemoraActiveReloaded
  426.  
  427.         bcf             FLAGS, PULSEONL         ;10ms is over, clear flags and
  428.         bsf             STATUS, RP0                     ;bank 1
  429.         bsf             GPIO, TRIGGERL  ;tristate output
  430.         bcf             STATUS, RP0                     ;bank 0
  431.  
  432.         call    Wait10ms
  433.         bsf             FLAGS, PULSEONL         ;if dwell is done turn on outputs
  434.         bsf             STATUS, RP0                     ;bank 1
  435.         bcf             GPIO, TRIGGERL  ;and reset pulse time
  436.         bcf             STATUS, RP0                     ;bank 0

Desconectado rivale

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1707
Re: Por favor ayuda...
« Respuesta #3 en: 31 de Mayo de 2011, 22:27:15 »
creo que te estas complicando mucho las cosas, trata de estructurar un poco mas tu programa.
para definir tus variables pon esto
Código: [Seleccionar]
CBLOCK 0x20
FLAGS
PULSER
.....
.
.
.
SHADOWP
ENDC

asi defines todas las variables que quieras sin tenerle que poner equ a todas
luego antes del main te recomiendo pongas una funcion para configurar tu pic como quieras, para que esto solo lo haga una vez

Código: [Seleccionar]
                    ORG 0X000
GOTO CONFIGURACION



CONFIGURACION
;aca pon las demas configuraciones que necesitas, como el osc, si necesitas puertos analogicos o algun modulo especifico
BANKSEL TRISIO ; con esto te cambias al banco donde esta el registro trisio
MOVLW B'00000010' ;se configuran todos como salida, excepto el gp1
MOVWF TRISIO ; se carga el valor al registro trisio
BANKSEL GPIO ;CAMBIA AL BANCO DEL PUERTO GPIO
BSF GPIO,4 ;PRENDES EL GP4
GOTO MAIN
MAIN
BTFSS GPI0,1 ;CHECA SI EL GP1 ESTA PRENDIDO
GOTO MAIN ;SI NO LO ESTA ENTONCES VUELVE AL MAIN
CALL RETARDO ;LLAMAS A LA FUNCION DEL RETARDO QUE QUERIAS, PD ACA NO ESTA ESCRITA ESA FUNCION
BANKSEL TRISIO
BCF TRISIO,1 ;vuelves salida el gp1
BANKSEL GPIO ;REGRESAS AL BANCO 0
BSF GPIO,1 ;PRENDES EL GP1
CALL RETARDO2 ;LLAMAS AL RETARDO QUE QUIERES QUE DURE EL PULSO EN TU PIN
BCF GPI0,1 ;APAGAS EL PIN
;ACA LO VUELVES A PONER COMO ENTRADA O LO QUE QUIERAS
GOTO MAIN                    

a grandes razgos asi quedaria el programa haciendo lo que decias cuando iniciaste el post asi ya es un bucle infinito, le puse lo que pedias al inico del post, espero haber entendido bien lo que querias hacer

faltan algunas cosas por agregar, continua con el programa y cualquier duda me dices
saludos
« Última modificación: 31 de Mayo de 2011, 22:29:18 por rivale »
"Nada es imposible, no si puedes imaginarlo"

Desconectado sQs

  • PIC10
  • *
  • Mensajes: 47
Re: Por favor ayuda...
« Respuesta #4 en: 31 de Mayo de 2011, 22:40:47 »
Ok lo voy a intentar pero veo que por ejemplo con esta intruccion

      MOVLW   B'00000010'      ;se configuran todos como salida, excepto el gp1
      MOVWF   TRISIO         ; se carga el valor al registro trisio

Aqui estamos afectando en realidad a todos los puertos, osea estamos configurando que todos queden como salida y el gp1 como entrada, ¿es posible que en lugar que la instruccion sea esa, habria manera de hacerlo por ejemplo manipular solo el gp1 sin afectar a los demas?

Desconectado rivale

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1707
Re: Por favor ayuda...
« Respuesta #5 en: 31 de Mayo de 2011, 22:46:25 »
si, en lugar de cargar el valor al registro completo puedes poner


bcf    trisio,1                     ;para poner en 0 el bit 1 del registro gpio

ó


bsf    trisio,1                     ;para poner en 1 el bit 1 del registro gpio


estas son instrucciones que afectan a un solo bit, dale una leida a las instrucciones del asm, para que escojas entre las que afectan bits o las que afectan bytes
"Nada es imposible, no si puedes imaginarlo"

Desconectado sQs

  • PIC10
  • *
  • Mensajes: 47
Re: Por favor ayuda...
« Respuesta #6 en: 31 de Mayo de 2011, 22:56:31 »
Es verdad ya me habia repasado todo el manual de ASM desde 0, solo que estaba un poco oxidado en el tema, muchas gracias mi estimado, pondre manos a la obra y cualquier detalle lo comento.

Desconectado rivale

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1707
Re: Por favor ayuda...
« Respuesta #7 en: 31 de Mayo de 2011, 23:06:03 »
ok, continua con tu programa y cualquier duda por aca sigo
"Nada es imposible, no si puedes imaginarlo"