TODOPIC
Microcontroladores PIC => Lenguaje Basic para microcontroladores PIC => Mensaje iniciado por: LordLafebre en 09 de Septiembre de 2007, 16:03:38
-
Hola:
Bueno, hasta hace poco, cuando quería trabajar con el USB, accedia normalmente al EasyHID y generaba el codigo, luego agregaba lo que necesitaba y compilaba, y al rato de cargar el hex en el Winpic, tenía que modificar la division del PLL a la del cristal que usaba, por lo tanto no podía usar la tecla F10 para que me cargue el HEX y programe directamente el micro por ese cambio que tenía que hacer, ahora al laaaargo tiempo desed que empecé con esto, he mirado los usibles y he hecho las configuraciones sigueintes para no tener que mmodificar nada en el winpic:
--------------------------------------------------------------------------------
@CONFIG_REQ
@PLL_REQ
@__config config1l, PLLDIV_3_1 & CPUDIV_1_1 & USBDIV_2_1
@__config config1h, FOSC_HSPLL_HS_1
@WATCHDOG_REQ
@__config config2h, WDT_OFF_2 & WDTPS_128_2
@DEBUG_REQ
@__config config4l, LVP_OFF_4 & ICPRT_OFF_4 & XINST_OFF_4 & DEBUG_OFF_4
@__config config3h, PBADEN_OFF_3
--------------------------------------------------------------------------------
La parte con el texto rojo, es la división del PLL, les ejo las divisiones:
PLLDIV_1_1 Oscillator not divided
PLLDIV_2_1 Oscillator divided by 2
PLLDIV_3_1 Oscillator divided by 3
PLLDIV_4_1 Oscillator divided by 4
PLLDIV_5_1 Oscillator divided by 5
PLLDIV_6_1 Oscillator divided by 6
PLLDIV_10_1 Oscillator divided by 10
PLLDIV_12_1 Oscillator divided by 12
Este código lo podemos agregar en nuestros programas y listo, no necesitamos tener que tocar nada en el winpic y solo darle F10 y programar normalmente :mrgreen:
Espero que les sirva, 8)
-
Gracias por el dato master,
-
No utilizo Proton, pero todas estas cosas me las anoto... Gracias Master
-
Ayuda please:
al compilar me sale el siguiente error...
ASM ERROR: Error[113] C:\DOCUMENTS AND SETTING\.......\PDS\A.S 3674 : Symbol not previously defined (CPUDIV_1_1)
ASM ERROR: Error[113] C:\DOCUMENTS AND SETTING\.......\PDS\A.S 3689 : Symbol not previously defined (ICPR_OFF_4)
¿como lo soluciono?
De antemano muchisimas gracias.
-
Es muy dificil ayudarte con solo mostrar el error que esta presentandote, debes poner el codigo para verlo y asi poderte ayudar mejor y que version del compilador tienes... :mrgreen:
Al parecer tienes un error en la declaracion de los fuses del pic, te adelanto eso :mrgreen:
-
El código, lo consegui con el EasyHID, cuando lo compilo tal cual no sale errores, cuando quiero programarlo con el PICKIT me sale una advertencia en fondo amarillo que dice …
Warning: Some configuration words not in hex file.
Ensure default values above righ are aceptable.
Aquí el código, el resto del programa lo adapte al voltimetro de Neoteo el descriptor es mio.
Por otra parte dicen que por defecto viene configurado para 20MHz en el Proton? Es eso cierto?
Uso el compilador PROTON IDE versión 2.0.1.0
'****************************************************************
'* Name : ADC SORIATEL *
'* Author : Xxxx X. Xxxxxx *
'* Notice : Copyright (c) 2013 - SORIATEL *
'* : All Rights Reserved *
'* Date : 25/07/2013 *
'* Version : 1.0 *
'* Notes : TEST HID *
'* : *
'****************************************************************
' SELECCIONAMOS EL PIC Y EL CRISTAL
Device = 18F2550
Xtal 48
Adin_Res 10 'AJUSTAMOS A UNA RESOLOCIÓN DE 10 BITS (0-5V = 0 - 1023)
Adin_Tad FRC 'ELEJIMOS EL OSCILADOR RC INTERNO PARA LAS MUESTRAS DEL ADC
Adin_Stime 100 'PERMITIMOS UNA RECARGA DEL ADC CADA 100uS
' EL ARCHIVO "DESCRIPTOR",ALOJADO EN EL MISMO DIRECTORIO QUE ESTE ARCHIVO .BAS
USB_Descriptor = "ADC_SORIATELDESC.inc"
' COMENZAMOS CON LA VARIABLES
Dim TENSION As ADRESL.Word ' \
Dim VALOR As Word ' \
Dim VOLT As Byte ' / VARIABLES PARA EL CONVERSOR ADC
Dim MILI As Byte ' /
Dim A As Byte 'VARIABLE PARA ACUMULAR MEDICIONES Y PROMEDIAR
Dim B As Byte 'VARIABLE PARA CONTAR ENVÍOS
' USB Buffer...
Symbol USBBufferSizeMax = 8
Symbol USBBufferSizeTX = 8 'CANTIDAD DE BYTES QUE ENTRAN EN EL BUFFER
Symbol USBBufferSizeRX = 8
Dim USBBuffer[USBBufferSizeMax] As Byte
' BANDERAS DEL SISTEMA.
Dim PP0 As Byte System ' STATUS DEL USBPOLL
Symbol CARRY_FLAG = STATUS.0 ' EN ESTADO ALTO CUANDO EL PIC NO TIENE EL CONTROL SOBRE EL BUFFER
Symbol ATTACHED_STATE = 6 ' CUANDO SE "ENGANCHA" EL BUS USB
'SETEO DEL ADC Y EL PUERTO A (AN0 SOLAMENTE ES ANALÓGICA)
TRISA.0 = 1 ' PORTA.0 ES UNA ENTRADA
ADCON1 = %10001110 ' PORTA.0 ES ANALÓGICA
ADCON2 = %10000000 ' EL RESULTADO DEL ADC JUSTIFICADO A LA DERECHA
' ************************************************************
' * LAZO PRINCIPAL DEL PROGRAMA - RECUERDA, TU DEBES MANTENER*
' * LA CONEXIÓN USB SIEMPRE "VIVA" LLAMANDO A LAS RUTINAS *
' * USBPoll, USBIn or USBOut CADA POCOS MILISEGUNDOS *
' ************************************************************
GoSub AttachToUSB
ProgramLoop:
For A = 1 To 20 'ARMO UN CONTADOR DE 20 EVENTOS PARA OBTENER
TENSION = ADIn 0 'MUCHAS MEDICIONES Y PROMEDIARLAS
VALOR = VALOR + TENSION 'PARA OBTENER UN VALOR MÁS ESTABLE
USBPoll 'ADEMÁS SE COLOCA EN EL HARD UN CAPACITOR DE 10uF
Next 'EN LA ENTRADA AN0 (A ENE CERO)
VALOR = VALOR / 20
VALOR = 489 * (TENSION / 10) 'ARMO EL RESULTADO PARA QUE 1023 SEA = A 5VOLTS
VOLT = VALOR / 10000 'SEPARO LOS VOLTS
MILI = (VALOR // 10000) / 100 'SEPARO LOS MILIVOLTS
USBBuffer[0] = 0 'EL PRIMER BYTE ES DE REPORTE DE CONEXIÓN
USBBuffer[1] = VOLT 'COLOCO LOS VOLTIOS EN EL BUFFER
USBBuffer[2] = MILI 'COLOCO LOS MILIVOLTIOS EN EL BUFFER
GoSub DoUSBOut 'TRANSMITO
DelayMS 1
GoTo ProgramLoop 'REINICIO EL CICLO DE MEDICIÓN INDEFINIDAMENTE
' ************************************************************
' * RUTINA DE RECEPCIÓN DE DATOS (NO USADA) *
' ************************************************************
DoUSBIn:
USBIn 1, USBBuffer, USBBufferSizeRX, DoUSBIn
Return
' ************************************************************
' * RUTINA DE TRANSMISIÓN DE DATOS *
' ************************************************************
DoUSBOut:
USBOut 1, USBBuffer, USBBufferSizeTX, DoUSBOut
Return
' ************************************************************
' * ESPERA HASTA QUE EL USB SE CONECTE *
' ************************************************************
AttachToUSB:
Repeat
USBPoll
Until PP0 = ATTACHED_STATE
Return
'*****************************************************************
Lo que le modifique fue esto…
Cristal de 20MHz:
Nota: En ProtonIDE, si no declaras el valor del cristal, por defecto lo compila para uno de 20Mhz., entonces no haría falta declararlo si vas a usar esa frecuencia. De todas formas la configuración es tal como lo ves y puede servirte de ejemplo para modificar otros "fuses" si en tu proyecto fuera necesario.
@CONFIG_REQ
@PLL_REQ
@__config config1l, PLLDIV_5_1 & CPUDIV_1_1 & USBDIV_2_1
@__config config1h, FOSC_HSPLL_HS_1
@WATCHDOG_REQ
@__config config2h, WDT_OFF_2 & WDTPS_128_2
@DEBUG_REQ
@__config config4l, LVP_OFF_4 & ICPRT_OFF_4 & XINST_OFF_4 & DEBUG_OFF_4
@__config config3h, PBADEN_OFF_3
Extracto de:
https://sites.google.com/site/proyectosroboticos/encoder/encoder-por-software/pic-encoder-usb/configuracion-del-cristal-para-18fxx5x-con-USB
-
En la configuracion de los fuses para la version del proton que tienes utiliza esto:
Config_Start
OSC = HS ' Oscillator Selection HS
OSCS = Off ' Osc. Switch Enable Disabled
PWRT = On ' Power-up Timer Enabled
BOR = Off ' Brown-out Reset Disabled
BORV = 25 ' Brown-out Voltage 2.5V
WDT = Off ' Watchdog Timer Disabled
WDTPS = 128 ' Watchdog Postscaler 1:128
CCP2MUX = On ' CCP2 MUX Enable (RC1)
STVR = Off ' Stack Overflow Reset Disabled
LVP = Off ' Low Voltage ICSP Disabled
DEBUG = Off ' Background Debugger Enable Disabled
CP0 = Off ' Code Protection Block 0 Disabled
CP1 = Off ' Code Protection Block 1 Disabled
CP2 = Off ' Code Protection Block 2 Disabled
CP3 = Off ' Code Protection Block 3 Disabled
CPB = Off ' Boot Block Code Protection Disabled
CPD = Off ' Data EEPROM Code Protection Disabled
WRT0 = Off ' Write Protection Block 0 Disabled
WRT1 = Off ' Write Protection Block 1Disabled
WRT2 = Off ' Write Protection Block 2 Disabled
WRT3 = Off ' Write Protection Block 3 Disabled
WRTB = Off ' Boot Block Write Protection Disabled
WRTC = Off ' Configuration Register Write Protection Disabled
WRTD = Off ' Data EEPROM Write Protection Disabled
EBTR0 = Off ' Table Read Protection Block 0 Disabled
EBTR1 = Off ' Table Read Protection Block 1 Disabled
EBTR2 = Off ' Table Read Protection Block 2 Disabled
EBTR3 = Off ' Table Read Protection Block 3 Disabled
EBTRB = Off ' Boot Block Table Read Protection Disabled
Config_End
La forma como lo declaras creo que es la forma antigua de hacerlo y no se sirva, en la ayuda del proton aparece lo que te coloque.
Tambien hay un programa llamado Fuses Configurator que te permite declarar los fuses de una manera rapida y sencilla :mrgreen: