Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: BlackZeroX en 1 Marzo 2011, 08:07 am



Título: [!] Liga interesante; Programando microcontroladores.
Publicado por: BlackZeroX en 1 Marzo 2011, 08:07 am
.
El compilador se llama Great Cow Basic y sirve para programar en los microchips.

* Es de codigo abierto.
* Free.
* Instalacion en Windows y Linux.
* Las variables tal y como son declaras, se ven reflejados en el codigo ASM final es decir no agrega nombres raros al codigo ASM final.

Manual es Español (https://sourceforge.net/projects/piclinux/files/GcBasic-PL/GcBasic_Manual.pdf/download)

http://gcbasic.sourceforge.net/index.html

Código
  1.  
  2. 'Led parpadeante
  3.  
  4. #chip 16F628A, 20      'modelo de pic y velocidad de reloj: 20 Mhz
  5.  
  6. #define led PORTB.1
  7.  
  8. Main:
  9.    TRISB=0
  10.    PORTB=0
  11.  
  12.    led = 1
  13.    wait 500 ms
  14.    led = 0
  15.    wait 500 ms
  16.  
  17. goto Main
  18.  
  19.  

Codigo ASM generado de manera limpia.

Código
  1.  
  2. ;Program compiled by Great Cow BASIC (0.9 13/9/2008)
  3. ;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
  4. ;check the documentation or email w_cholmondeley@users.sourceforge.net.
  5.  
  6. ;********************************************************************************
  7.  
  8. ;Set up the assembler options (Chip type, clock source, other bits and pieces)
  9. LIST p=16F628A, r=DEC
  10. #include
  11. __CONFIG _HS_OSC & _WDT_OFF & _LVP_OFF & _MCLRE_OFF
  12.  
  13. ;********************************************************************************
  14.  
  15. ;Set aside memory locations for variables
  16. DELAYTEMP   equ    32
  17. DELAYTEMP2   equ    33
  18. RANDOMSEED   equ    34
  19. RANDOMSEED_H   equ    35
  20. SysWaitTempMS   equ    36
  21. SysWaitTempMS_H   equ    37
  22.  
  23. ;********************************************************************************
  24.  
  25. ;Jump to initialisation code when PIC is reset
  26.    ORG    0
  27.    call    INITSYS
  28.    goto    SystemInitialise
  29.  
  30. ;********************************************************************************
  31.  
  32. ;Interrupt vector
  33.    ORG    4
  34. ;Various initialisation routines, automatically called by GCBASIC
  35. SystemInitialise
  36.  
  37. ;********************************************************************************
  38.  
  39. ;Start of the main program
  40. MAIN
  41.    banksel    TRISB
  42.    clrf    TRISB
  43.    banksel    PORTB
  44.    clrf    PORTB
  45.    bsf    PORTB,1
  46.    movlw    244
  47.    movwf    SysWaitTempMS
  48.    movlw    1
  49.    movwf    SysWaitTempMS_H
  50.    call    Delay_MS
  51.    bcf    PORTB,1
  52.    movlw    244
  53.    movwf    SysWaitTempMS
  54.    movlw    1
  55.    movwf    SysWaitTempMS_H
  56.    call    Delay_MS
  57.    goto    MAIN
  58. BASPROGRAMEND
  59.    sleep
  60.    goto    $
  61.  
  62. ;********************************************************************************
  63. ;Subroutines included in program
  64. ;********************************************************************************
  65.  
  66. Delay_MS
  67.    incf    SysWaitTempMS_H, F
  68. DMS_START
  69.    movlw    10
  70.    movwf    DELAYTEMP2
  71. DMS_OUTER
  72.    movlw    166
  73.    movwf    DELAYTEMP
  74. DMS_INNER
  75.    decfsz    DELAYTEMP, F
  76.    goto    DMS_INNER
  77.    decfsz    DELAYTEMP2, F
  78.    goto    DMS_OUTER
  79.    decfsz    SysWaitTempMS, F
  80.    goto    DMS_START
  81.    decfsz    SysWaitTempMS_H, F
  82.    goto    DMS_START
  83.    return
  84.  
  85. ;********************************************************************************
  86.  
  87. INITSYS
  88.    movlw    7
  89.    movwf    CMCON
  90.    clrf    PORTA
  91.    clrf    PORTB
  92.    return
  93.  
  94. ;********************************************************************************
  95.  
  96. END
  97.  
  98.  

Dulces Lunas!¡.


Título: Re: [!] Liga interesante; Programando microcontroladores.
Publicado por: extreme69 en 1 Marzo 2011, 08:16 am
Jeje, yo tenía buenas ideas para usar microcontroladores... quería hacer un sistema de riego con microcontroladores PIC y un horno solar que te avisara cuando la comida estaba lista  :xD

Usaba "PICBASIC" o algo así... fue hace años...

BlackZeroX vos que siempre me salvás con VB leete mi último thread please, el control mscomm no me está funcionando y ya no sé que hacer.