TODOPIC
Microcontroladores PIC => Lenguaje Basic para microcontroladores PIC => Mensaje iniciado por: NORTEÑO en 09 de Enero de 2013, 09:27:05
-
hola:
Tengo un problema sobre programacion en mikrobasic
que estoy seguro que ustedes me puede ayudar.
consiste en lo siguiente:
deseo hacer una funcion.
tal que al pasar parametros pueda cambiar sus contenidos.
en lo referente a los registros TRISA, B, C, D, E
dentro de la funcion.
ejemplo:
Sub Funcion RCTimeout(dim byref Puerto as byte,dim Pin as byte,dim CUENTAS as word)as word
'ANSEL = 0
'ANSELH = 0
'C1ON_bit = 0
'C2ON_bit = 0
TRISA = 0 '??????? configuracion puerto de salida OUPUT A
while TRUE 'bien bucle A
TRISA = 0 '?????????????
(Puerto,Pin) = 1 'bien
delay_ms (50) 'bien carga del condensador 50 ms
CUENTAS = 0 'bien contador
TRISA.0 = 1 '?????????????
----------------------------------------------------------------------
----------------------------------------------------------------------
Puerto.Pin = 0 'bien
while (Puerto.Pin = 1) 'bien BUCLE B
TRISA.0 = 0 '?????????????
Puerto.Pin = 1 'bien
TRISA.0 = 1 '?????????????
inc(CUENTAS) 'bien
wend 'bien FIN BUCLE B
'wend 'bien FIN BUCLE A
result = CUENTAS 'bien
End sub 'bien
************************************************************
GRACIAS.
-
Si te he entendido bien Lo más simple es esto:
dim io as bit
io = 0 ó 1
TRISA = 0
If pin = 0 Then TRISA.0 = io
If pin = 1 Then TRISA.1 = io
.
.
.
-
hola a todos.
Creo que voy por buen camino. pero NO FUNCIONA, o no se hacer funcionar esta funcion en mikrobasic.
Quien puede ayudarme ???
------------------------------------------------ FUNCION-----------------
Sub function POT(dim byref port as byte,dim Pin as byte,dim cuentas as word)as word
dim reg_sal as byte
if port = PORTA then
TRISA = 0
TRISA.pin = 1
reg_sal = TRISA
end if
if port = PORTB then
TRISB = 0
TRISB.pin = 1
reg_sal = TRISB
end if
if port = PORTC then
TRISC = 0
TRISC.pin = 1
reg_sal = TRISC
end if
if port = PORTD then
TRISD = 0
TRISD.pin = 1
reg_sal = TRISD
end if
if port = PORTE then
TRISE = 0
TRISE.pin = 1
reg_sal = TRISE
end if
cuentas = 0
port.pin = 0
while (port.pin = 1) 'bien
reg_sal.pin = 0 'TRISA.0 = 0
port.pin = 1 'bien
reg_sal.pin = 1 'TRISA.0 = 1
inc(cuentas) 'bien
wend
result = cuentas
End sub
-------------------------------------
Donde esta el error.