TODOPIC
Microcontroladores PIC => Lenguaje Basic para microcontroladores PIC => Mensaje iniciado por: Noelillo en 11 de Septiembre de 2011, 17:00:38
-
'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : Miguel Noe Garcia Perez *
'* Notice : Copyright (c) 2011 Iberica 2000 *
'* : All Rights Reserved *
'* Date : 11/09/2011 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
DEVICE 16F877a
XTAL = 4
LCD_TYPE = GRAPHIC ' Use a Graphic LCD
' Graphic LCD Pin Assignments
LCD_DTPORT = PORTD
LCD_RSPIN = PORTC.2
LCD_RWPIN = PORTE.0
LCD_ENPIN = PORTC.5
LCD_CS1PIN = PORTE.2
LCD_CS2PIN = PORTE.1
DECLARE GLCD_CS_INVERT on
DECLARE INTERNAL_FONT on ' Use an internal chr set
SCL_PIN = PORTC.4
SDA_PIN = PORTC.3
ALL_DIGITAL = ON ' Set PORTA and PORTE to all digital
' Define ADC parameters
ADIN_RES = 10 ' 10-bit result required
ADIN_TAD = FRC ' RC OSC chosen
ADIN_STIME = 50 ' Allow 50us sample time
'_______________________________________________________________
PORTB_PULLUPS = ON ' Enable PORTB pull-ups
TRISA = %00000010 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
'********************* dim ********************************
DIM Xpos as BYTE
DIM Ypos as BYTE
dim BaudMode[7] as word
dim Btnvar as byte ' Teclas
dim Datos [128] as word
dim Baudios as byte
DIM SerData AS BYTE
Dim Index As word ' Variable de uso general
dim X as byte
dim Coder as byte
dim Grabar as byte
dim N as word
'******************************************************************************************
'********************* SIMBOLOS DEL PROGRAMA *********************************************
'******************************************************************************************
Symbol DQ = PORTc.1 ' Pin de conexión 1-Wire®
Symbol SW1 = PORTb.0 ' Interruptor Set
Symbol SW2 = PORTB.1 ' Interruptor Incre
Symbol SW3 = PORTB.2 ' Interruptor Intro
symbol Led = portc.7
BaudMode[1] = 19697
BaudMode[2] = 18030
BaudMode[3] = 17197
BaudMode[4] = 16780
BaudMode[5] = 16572
BaudMode[6] = 16468
'**************************** iniciar Variable *******************
Baudios = 1
grabar = 0
'******************* INICIO **********************************************************
Delayms 500 ' Wait .5 second
Cls
Print At 3,7,"M S X"
DelayMS 2000
Cls
Print At 0,0,"MSX BASIC version2.1"
Print At 1,0,"Copyright 1986 by"
Print At 2,0,"Microsoft"
Print At 3,0,"Ok"
Print At 7,0,"color auto goto list"
DelayMS 500
cls
Print At 3,7,"S P Y II"
DELAYMS 500
Star:
gosub Menu
'*********************** boton ***************************
AA: button sw1,0,255,250,Btnvar,0,BB
goto Escucha
BB: button sw2,0,255,250,Btnvar,0,CC
goto Graba
CC: button sw3,0,255,250,Btnvar,0,AA
GOTO Emitir
'*********************************************************
Escucha:
circle 1,15,19,1
delayms 200
cls
print at 0,2,"Selecciona Baudios"
circle 1,15,19,2
circle 1,15,27,2
circle 1,15,35,2
circle 1,15,43,2
circle 1,15,51,2
circle 1,15,59,2
print at 2,4,"300 Baud"
print at 3,4,"600 Baud"
print at 4,4,"1200 Baud"
print at 5,4,"2400 Baud"
print at 6,4,"4800 Baud"
print at 7,4,"9600 Baud"
Seleccion:
if baudios = 1 then circle 1,15,19,1
if baudios = 2 then circle 1,15,27,1:circle 0,15,19,1
if baudios = 3 then circle 1,15,35,1:circle 0,15,27,1
if baudios = 4 then circle 1,15,43,1:circle 0,15,35,1
if baudios = 5 then circle 1,15,51,1:circle 0,15,43,1
if baudios = 6 then circle 1,15,59,1:circle 0,15,51,1
if baudios > 6 then Baudios = 1:circle 0,15,59,1:circle 1,15,19,1
'********************************************
AAA: button sw1,0,255,250,Btnvar,0,BBB
delayms 200: baudios = baudios +1:goto seleccion
BBB: button sw2,0,255,250,Btnvar,0,AAA
goto Escuchando
stop
Escuchando:
cls
print at 0,0,"Escuchando..."
for Index = 0 to 127
SERIN PORTc.6 ,BaudMode[baudios],[SerData]
'print at 0,15,dec3 index
DATOS [iNDEX] = SERDATA
Next
x=0
for index = 1 to 21
Coder = Datos[Index]
print at 1,x,dec1 Coder
x=x+1
next
x=0
for index = 22 to 42
Coder = Datos[Index]
print at 2,x,dec1 Coder
x=x+1
next
x=0
for index = 43 to 63
Coder = Datos[Index]
print at 3,x,dec1 Coder
x=x+1
next
x=0
for index = 64 to 84
Coder = Datos[Index]
print at 4,x,dec1 Coder
x=x+1
next
x=0
for index = 85 to 105
Coder = Datos[Index]
print at 5,x,dec1 Coder
x=x+1
next
x=0
for index = 104 to 124
Coder = Datos[Index]
print at 6,x,dec1 Coder
x=x+1
next
grabar = 1
print at 7,9,"FIN"
CCCC: button sw3,0,255,250,Btnvar,0,AAAA
delayms 200:GOTO Star
AAAA:
goto cccc
stop
Graba:
circle 1,15,27,1
delayms 200
cls
if grabar = 0 then print at 3,0,"No Hay datos":delayms 500:goto star
print at 3,0,"GRABANDO"
for n = 0 to 128
ewrite n,[datos[n]]
next n
CLS
GOTO STAR
stop
Emitir:
circle 1,15,35,1
delayms 200
cls
PRINT AT 3,0,"Emitiendo"
high led
FOR N= 0 TO 127
Coder = Datos[N]
Serout portc.0,BaudMode[baudios],[CODER] ' Display "Hello", next line
NEXT
low led
delayms 200
cls
goto star
stop
'******************* gosub ***************************
Menu:
CLS '123456789012345678901
print at 0,0,"_______ Menu _______"
CIRCLE 1,15,19,2
print at 2,4,"Escuchar"
circle 1,15,27,2
print at 3,4,"Grabar"
circle 1,15,35,2
print at 4,4,"Emitir grabacion"
print at 7,5,"Pulsa Boton"
return
end
' Letras
font:-
Cdata $00,$00,$00,$00,$00,$00,_
$FF,$FF,$FF,$FF,$FF,$FF,_
$07,$07,$07,$00,$00,$00,_
$00,$00,$00,$07,$07,$07,_
$E0,$E0,$E0,$00,$00,$00,_
$00,$00,$00,$E0,$E0,$E0,_
$FF,$FF,$FF,$00,$00,$00,_
$00,$00,$00,$FF,$FF,$FF,_
$07,$07,$07,$07,$07,$07,_
$E0,$E0,$E0,$E0,$E0,$E0,_
$E0,$E0,$E0,$07,$07,$07,_
$07,$07,$07,$E0,$E0,$E0,_
$FF,$FF,$FF,$E0,$E0,$E0,_
$E0,$E0,$E0,$FF,$FF,$FF,_
$07,$07,$07,$FF,$FF,$FF,_
$FF,$FF,$FF,$07,$07,$07,_
$55,$AA,$55,$AA,$55,$AA,_
$AA,$55,$AA,$55,$AA,$55,_
$01,$01,$01,$01,$01,$01,_
$80,$80,$80,$80,$80,$80,_
$FF,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$FF,_
$FF,$01,$01,$01,$01,$01,_
$01,$01,$01,$01,$01,$FF,_
$FF,$80,$80,$80,$80,$80,_
$80,$80,$80,$80,$80,$FF,_
$00,$00,$06,$09,$09,$06,_
$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,_
$00,$00,$4F,$00,$00,$00,_
$00,$07,$00,$07,$00,$00,_
$14,$7F,$14,$7F,$14,$00,_
$24,$2A,$7F,$2A,$12,$00,_
$23,$13,$08,$64,$62,$00,_
$36,$49,$55,$22,$50,$00,_
$00,$05,$03,$00,$00,$00,_
$1C,$22,$41,$00,$00,$00,_
$00,$00,$41,$22,$1C,$00,_
$14,$08,$3E,$08,$14,$00,_
$08,$08,$3E,$08,$08,$00,_
$00,$50,$30,$00,$00,$00,_
$08,$08,$08,$08,$08,$00,_
$00,$60,$60,$00,$00,$00,_
$20,$10,$08,$04,$02,$00,_
$3E,$51,$49,$45,$3E,$00,_
$00,$42,$7F,$40,$00,$00,_
$42,$61,$51,$49,$46,$00,_
$21,$41,$45,$4B,$31,$00,_
$18,$14,$12,$7F,$10,$00,_
$27,$45,$45,$45,$39,$00,_
$3C,$4A,$49,$49,$30,$00,_
$01,$71,$09,$05,$03,$00,_
$36,$49,$49,$49,$36,$00,_
$06,$49,$49,$49,$3E,$00,_
$00,$36,$36,$00,$00,$00,_
$00,$56,$36,$00,$00,$00,_
$08,$14,$22,$41,$00,$00,_
$14,$14,$14,$14,$14,$00,_
$00,$41,$22,$14,$08,$00,_
$02,$01,$51,$09,$06,$00,_
$32,$49,$79,$41,$3E,$00,_
$7E,$11,$11,$11,$7E,$00,_
$7F,$49,$49,$49,$36,$00,_
$3E,$41,$41,$41,$22,$00,_
$7F,$41,$41,$22,$1C,$00,_
$7F,$49,$49,$49,$41,$00,_
$7F,$09,$09,$09,$01,$00,_
$3E,$41,$49,$49,$7A,$00,_
$7F,$08,$08,$08,$7F,$00,_
$00,$41,$7F,$41,$00,$00,_
$20,$40,$41,$3F,$01,$00,_
$7F,$08,$14,$22,$41,$00,_
$7F,$40,$40,$40,$40,$00,_
$7F,$02,$0C,$02,$7F,$00,_
$7F,$04,$08,$10,$7F,$00,_
$3E,$41,$41,$41,$3E,$00,_
$7F,$09,$09,$09,$06,$00,_
$3E,$41,$51,$21,$5E,$00,_
$7F,$09,$19,$29,$46,$00,_
$46,$49,$49,$49,$31,$00,_
$01,$01,$7F,$01,$01,$00,_
$3F,$40,$40,$40,$3F,$00,_
$1F,$20,$40,$20,$1F,$00,_
$3F,$40,$38,$40,$3F,$00,_
$63,$14,$08,$14,$63,$00,_
$07,$08,$70,$08,$07,$00,_
$61,$51,$49,$45,$43,$00,_
$7F,$41,$41,$00,$00,$00,_
$02,$04,$08,$10,$20,$00,_
$00,$00,$41,$41,$7F,$00,_
$04,$02,$01,$02,$04,$00,_
$40,$40,$40,$40,$40,$00,_
$00,$01,$02,$04,$00,$00,_
$20,$54,$54,$54,$78,$00,_
$7F,$48,$44,$44,$38,$00,_
$38,$44,$44,$44,$20,$00,_
$38,$44,$44,$48,$7F,$00,_
$38,$54,$54,$54,$18,$00,_
$08,$7E,$09,$01,$02,$00,_
$0C,$52,$52,$52,$3E,$00,_
$7F,$08,$04,$04,$78,$00,_
$00,$44,$7D,$40,$00,$00,_
$00,$20,$40,$44,$3D,$00,_
$7F,$10,$28,$44,$00,$00,_
$00,$41,$7F,$40,$00,$00,_
$7C,$04,$18,$04,$78,$00,_
$7C,$08,$04,$04,$78,$00,_
$38,$44,$44,$44,$38,$00,_
$7C,$14,$14,$14,$08,$00,_
$08,$14,$14,$18,$7C,$00,_
$7C,$08,$04,$04,$08,$00,_
$48,$54,$54,$54,$20,$00,_
$04,$3F,$44,$40,$20,$00,_
$3C,$40,$40,$20,$7C,$00,_
$1C,$20,$40,$20,$1C,$00,_
$3C,$40,$30,$40,$3C,$00,_
$44,$28,$10,$28,$44,$00,_
$0C,$50,$50,$50,$3C,$00,_
$44,$64,$54,$4C,$44,$00,_
$08,$36,$41,$00,$00,$00,_
$00,$00,$7F,$00,$00,$00,_
$00,$00,$41,$36,$08,$00,_
$00,$08,$04,$08,$04,$00
:)
-
Este es el esquema.