prueva con usart.h y masterI2C.h

Publicar nuevo tema   Responder al tema

Página 1 de 2. 1, 2  Siguiente

Ver el tema anterior Ver el tema siguiente Ir abajo

prueva con usart.h y masterI2C.h

Mensaje  alejandro el Vie 11 Sep 2009 - 23:47

ahora,ya que el rover serà escrito totalmente en gcbasic he comenzado ha escribir un fw de prueva entre el master(16F767) y uno de los slave(en este caso el 16F88 dedicado a la comunicaciòn con el pc a traves de un modulo radio).el codigo es este:
Código:

'******************************************************************************************
'******** CONFIGURACION DEL PIC **********************************************
'******************************************************************************************
#chip 16f88,20
#config OSC=HS,WDT_OFF,PWRTE_ON,MCLR_ON,CP_OFF
#include                  'libreria I2C slave
#include                              'libreria USART
'''''''''''''''''''''''''''''''''' Setup USART module '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#define USART_BAUD_RATE 600                   
#define USART_BLOCKING
'''''''''''''''''''''''''''''''''' Setup SSP module '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#define Slv_Comunicacion b'00111100'          'Configuro Pic_Slave I2C_address
#define BufferLen 1                            'Cuantos byte en recepciòn para activar el interrupt
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim RxBuffer(RxBufferSize) 
DIR PORTA b'00000'                            'Puerto A todos out
DIR PORTB b'00010110'                          'Puerto B 1/2/4 in,los demas out
PORTA=b'00000'                                'Puerto A todos down
PORTB=b'00000000'                              'Puerto B todos down
InitUSART                                      'Setup USART
InitSSP                                        'Configuraciòn registros SSP y activar el interrupt 
Main:
  Interrupt                                  'En caso de interrupt
  TestLed = RxBuffer(1)                      'Recibe byte del Master
  HserPrint "Test"
  HserSend TestLed
  HserPrint "#®"
  wait 10 ms
  Rotate TestLed Right
  PortB.0 = Status.C 
  Rotate TestLed Right
  PortB.3 = Status.C 
  Rotate TestLed Right
  PortB.6 = Status.C 
  Rotate TestLed Right
  PortB.7 = Status.C 
  goto Main

el problema que me da este error:
Strumento in esecuzione: gcbasic

Great Cow BASIC (0.9 16/6/2009)

Compilando /home/alejandro/Scrivania/Robot/Rover/Firmware/16F88/Control_transmiciòn.gcb ...
Segmentation fault

Uscito: 35584

alejandro
Participante Activo
Participante Activo

Cantidad de envíos: 41
Fecha de inscripción: 12/02/2009

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  Pikitin el Sáb 12 Sep 2009 - 3:41

Que tal Alejandro?

Creo que el problema está en las interrupciones.
Nosé como funciona la librería I2C que estás usando, pero creo que una forma más correcta de manejar las interrupciones es esta:

Código:

'******************************************************************************************
'******** CONFIGURACION DEL PIC **********************************************
'******************************************************************************************
#chip 16f88,20
#config OSC=HS,WDT_OFF,PWRTE_ON,MCLR_ON,CP_OFF
#include                  'libreria I2C slave
#include                              'libreria USART

'Setup USART module '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#define USART_BAUD_RATE 600                   
#define USART_BLOCKING

'Setup SSP module '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#define Slv_Comunicacion b'00111100'          'Configuro Pic_Slave I2C_address
#define BufferLen 1                            'byte para activar el interrupt

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim RxBuffer(RxBufferSize) 
DIR PORTA b'00000'                            'Puerto A todos out
DIR PORTB b'00010110'                          'Puerto B 1/2/4 in,los demas out

PORTA=b'00000'                                'Puerto A todos down
PORTB=b'00000000'                              'Puerto B todos down

InitUSART                                      'Setup USART
InitSSP                                        'Configuraciòn SSP, interrupt
 

Do            'Bucle principal: no hace nada

Loop          'Fin de bucle principal

Sub Interrupt                                  'Subrutina interrupciones
  TestLed = RxBuffer(1)                      'Recibe byte del Master
  HserPrint "Test"
  HserSend TestLed
  HserPrint "#®"
  wait 10 ms
  Rotate TestLed Right
  PortB.0 = Status.C 
  Rotate TestLed Right
  PortB.3 = Status.C 
  Rotate TestLed Right
  PortB.6 = Status.C 
  Rotate TestLed Right
  PortB.7 = Status.C 
End Sub



De todas formas hay un par de cosas:
- Que versión de GcBasic usas? ( al compilar te sale algo como esto: Great Cow BASIC (0.9 12/8/2009) )

- 600 baudios es muy lento, supongo que lo haces por algo, pero es demasiado lento para un reloj de 20 MHz.
Si no puedes poner una velocidad más alta, creo que deberías poner un reloj más lento.
Otra posiblidad sería utlizar rs232 por software.

- Si recibes datos por I2C muy rápidos quizás tengas problemas, porque la rutina usart es muy lenta, además tienes un retardo de 10 ms... si en ese tiempo recibes varios datos por I2C no sé si vá a funcionar bién...


Estaría muy bién que me mandaras la librería I2C y ponerla en "descargas"



Saludos.

Pikitin
veterano
veterano

Cantidad de envíos: 332
Fecha de inscripción: 26/11/2008

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  alejandro el Sáb 12 Sep 2009 - 10:04

la versiòn de GCBasic es la 0.9
Código:
'''''''''''''''''''''''''''''''''' CONFIGURACION DEL PIC ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#chip 16f88,20
#config OSC=HS,WDT_OFF,PWRTE_ON,MCLR_ON,CP_OFF
#include                  'libreria I2C slave
#include                              'libreria USART
'''''''''''''''''''''''''''''''''' MODULO USART '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#define USART_BAUD_RATE 600                    'Configuro Vicky a 600 baud de transmiciòn

#define USART_BLOCKING
'''''''''''''''''''''''''''''''''' MODULO SSP '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#define Slv_Comunicacion b'00111100'          'Configuro Pic_Slave I2C_address
#define BufferLen 1                            'Cuantos byte en recepciòn para activar el interrupt
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim RxBuffer(RxBufferSize) 
DIR PORTA b'00000'                            'Puerto A todos out
DIR PORTB b'00010110'                          'Puerto B 1/2/4 in,los demas out
PORTA=b'00000'                                'Puerto A todos down
PORTB=b'00000000'                              'Puerto B todos down
InitUSART                                      'Setup USART
InitSSP                                        'Configuraciòn registros SSP y activar el interrupt 

Sub Interrupt                                  'Subrutina interrupciones
  TestLed = RxBuffer(1)                        'Recibe byte del Master
  HserPrint "Test"
  HserSend TestLed
  HserPrint "#®"
  wait 10 ms
  Rotate TestLed Right
  PortB.0 = Status.C
  Rotate TestLed Right
  PortB.3 = Status.C
  Rotate TestLed Right
  PortB.6 = Status.C
  Rotate TestLed Right
  PortB.7 = Status.C
End Sub

Do
'''''''''
Loop

da el mismo error
la velocidad de 600 baudios es por lòs modulos radios economicos.ha esa velocidad recibe bien.veremos despuès.
este es el codigo con la libreria RS232 y compila bien.
Código:
#chip 16f88,20
#config OSC=HS,WDT_OFF,PWRTE_ON,MCLR_ON,CP_OFF
#include                  'libreria I2C slave
'''''''''''''''''''''''''''''''''' Setup USART module '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
InitSer 1,r600,1+WaitForStart,8,1,none,normal
'''''''''''''''''''''''''''''''''' Setup SSP module '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#define Slv_Comunicacion b'00111100'          'Configuro Pic_Slave I2C_address
#define BufferLen 1                            'Cuantos byte en recepciòn para activar el interrupt
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim RxBuffer(RxBufferSize) 
DIR PORTA b'00000'                            'Puerto A todos out
DIR PORTB b'00010110'                          'Puerto B 1/2/4 in,los demas out
PORTA=b'00000'                                'Puerto A todos down
PORTB=b'00000000'                              'Puerto B todos down
InitSSP                                        'Configuraciòn registros SSP y activar el interrupt 
Main:
  Interrupt                                  'En caso de interrupt
  TestLed = RxBuffer(1)                      'Recibe byte del Master
  SerSend 1,84
  SerSend 1,101
  SerSend 1,115
  SerSend 1,116

  SerSend 1,TestLed
  SerSend 1,35
  SerSend 1,169

  wait 25 ms
  Rotate TestLed Right
  PortB.0 = Status.C 
  Rotate TestLed Right
  PortB.3 = Status.C 
  Rotate TestLed Right
  PortB.6 = Status.C 
  Rotate TestLed Right
  PortB.7 = Status.C 
  goto Main 

lo cambierò para crear la sub interrupt y el delay de la rs232

alejandro
Participante Activo
Participante Activo

Cantidad de envíos: 41
Fecha de inscripción: 12/02/2009

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  Pikitin el Sáb 12 Sep 2009 - 11:51

la versiòn de GCBasic es la 0.9


Si.. pero ¿has instalado el último update?
Eso lo ves en la fecha: Great Cow BASIC (0.9 12/8/2009)

Si no lo tienes, instálalo porque se resuelven algunos problemas con las interrupciones.

Si vas a utilizar rs232 por software creo que tienes que definir los pines Rx y TX.

Pikitin
veterano
veterano

Cantidad de envíos: 332
Fecha de inscripción: 26/11/2008

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  alejandro el Sáb 12 Sep 2009 - 16:28

tenes el link?

alejandro
Participante Activo
Participante Activo

Cantidad de envíos: 41
Fecha de inscripción: 12/02/2009

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  alejandro el Sáb 12 Sep 2009 - 17:29

Código:
#chip 16f88,20
#config OSC=HS,WDT_OFF,PWRTE_ON,MCLR_ON,CP_OFF
#include <SSP_I2C_PicSlave.h>                  'libreria I2C slave
#define Slv_Comunicacion b'00111100'            'Configuro Pic_Slave I2C_address
#define BufferLen 1                            'Cuantos byte en recepciòn para activar el interrupt
#define USART_BAUD_RATE 600                    'Configuro a 600 baud de transmiciòn

#define USART_BLOCKING
Dim RxBuffer(RxBufferSize) 
DIR PORTA b'00000'                              'Puerto A todos out
DIR PORTB b'00010110'                          'Puerto B 1/2/4 in,los demas out
PORTA=b'00000'                                  'Puerto A todos down
PORTB=b'00000000'                              'Puerto B todos down
InitSSP                                        'Configuraciòn registros SSP y activar el interrupt 

InitUSART

'Sub Interrupt                                  'Subrutina interrupciones
'  TestLed = RxBuffer(1)                        'Recibe byte del Master
'  HserPrint "Test"

'  HserSend TestLed

'  HserPrint "#®"

'  wait 10 ms
'  Rotate TestLed Right
'  PortB.0 = Status.C 
'  Rotate TestLed Right
'  PortB.3 = Status.C 
'  Rotate TestLed Right
'  PortB.6 = Status.C 
'  Rotate TestLed Right
'  PortB.7 = Status.C 
'End Sub

do
  Interrupt                                    'En caso de interrupt
  TestLed = RxBuffer(1)                        'Recibe byte del Master
  HserPrint "Test"

  HserSend TestLed

  HserPrint "#®"

  wait 10 ms
  Rotate TestLed Right
  PortB.0 = Status.C 
  Rotate TestLed Right
  PortB.3 = Status.C 
  Rotate TestLed Right
  PortB.6 = Status.C 
  Rotate TestLed Right
  PortB.7 = Status.C 
loop

ahora viene compilado sin errores.tenia que poner la nueva libreria usart.h en gcbasic/include/lowlevel
pero el sub interrupt no.

alejandro
Participante Activo
Participante Activo

Cantidad de envíos: 41
Fecha de inscripción: 12/02/2009

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  Pikitin el Sáb 12 Sep 2009 - 22:59

La última actualización de GcBasic la puedes encontrar aquí:

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

Cuando instales el update ya no hace falta #incluir la nueva librería usart.h porque ya viene incluida.

Pikitin
veterano
veterano

Cantidad de envíos: 332
Fecha de inscripción: 26/11/2008

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  alejandro el Dom 13 Sep 2009 - 18:34

ho instalado el update,resultado..........igual que antes.
Código:
'''''''''''''''''''''''''''''''''''''' CONFIGURACION DEL PIC '''''''''''''''''''''''''''''''''''''''''''
#chip 16f88,20
#config OSC=HS,WDT_OFF,PWRTE_ON,MCLR_ON,CP_OFF
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#include <SSP_I2C_PicSlave.h>                  'libreria I2C slave
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#define Slv_Comunicacion b'00111100'            'Configuro Pic_Slave I2C_address
#define BufferLen 1                            'Cuantos byte en recepciòn para activar el interrupt
#define USART_BAUD_RATE 600                    'Configuro a 600 baud de transmiciòn

#define USART_BLOCKING
Dim RxBuffer(RxBufferSize) 
DIR PORTA b'00000'                              'Puerto A todos out
DIR PORTB b'00010110'                          'Puerto B 1/2/4 in,los demas out
PORTA=b'00000'                                  'Puerto A todos down
PORTB=b'00000000'                              'Puerto B todos down
InitSSP                                        'Configuraciòn registros SSP y activar el interrupt 

InitUSART

Sub Interrupt                                  'Subrutina interrupciones
  TestLed = RxBuffer(1)                      'Recibe byte del Master
  HserPrint "Test"

  HserSend TestLed

  HserPrint "#®"

  wait 10 ms
  Rotate TestLed Right
  PortB.0 = Status.C 
  Rotate TestLed Right
  PortB.3 = Status.C 
  Rotate TestLed Right
  PortB.6 = Status.C 
  Rotate TestLed Right
  PortB.7 = Status.C 
End Sub

Do
''''''''''''''''''''''''''
Loop

responde
Código:
Strumento in esecuzione: gcbasic

Great Cow BASIC (0.9 16/6/2009)

Compiling /home/alejandro/Scrivania/Robot/Rover/Firmware/16F88/Control_transmiciòn.gcb ...
Segmentation fault

Uscito: 35584

en cambio con
Código:
do
  Interrupt                                    'En caso de interrupt
  TestLed = RxBuffer(1)                        'Recibe byte del Master
  HserPrint "Test"

  HserSend TestLed

  HserPrint "#®"

  wait 10 ms
  Rotate TestLed Right
  PortB.0 = Status.C 
  Rotate TestLed Right
  PortB.3 = Status.C 
  Rotate TestLed Right
  PortB.6 = Status.C 
  Rotate TestLed Right
  PortB.7 = Status.C 
loop

todo ok,estàs seguro que exixte una sub Interrupt.esa sub existe en mikrobasic.

alejandro
Participante Activo
Participante Activo

Cantidad de envíos: 41
Fecha de inscripción: 12/02/2009

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  alejandro el Dom 13 Sep 2009 - 19:40

Código:
'''''''''''''''''''''''''''''''''''''' CONFIGURACION DEL PIC '''''''''''''''''''''''''''''''''''''''''''
#chip 16f88,20
#config OSC=HS,WDT_OFF,PWRTE_ON,MCLR_ON,CP_OFF
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#include                    'libreria I2C slave
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#define Slv_Comunicacion b'00111100'            'Configuro Pic_Slave I2C_address
#define BufferLen 1                            'Cuantos byte en recepciòn para activar el interrupt
#define USART_BAUD_RATE 600                    'Configuro a 600 baud de transmiciòn

#define USART_BLOCKING
Dim RxBuffer(RxBufferSize) 
DIR PORTA b'00000'                              'Puerto A todos out
DIR PORTB b'00010110'                          'Puerto B 1/2/4 in,los demas out
PORTA=b'00000'                                  'Puerto A todos down
PORTB=b'00000000'                              'Puerto B todos down
InitSSP                                        'Configuraciòn registros SSP y activar el interrupt 

InitUSART

On Interrupt PORTBChange call Interrupt_I2C_Serial

Sub Interrupt_I2C_Serial                        'Subrutina interrupciones
    if PIR1.SSPIF=1 then                        'si la recedpciòn se verificò......
      TestLed=RxBuffer(1)                        'Recibe byte del Master
      HserPrint "Test"

      HserSend TestLed

      HserPrint "#®"

      wait 10 ms
      Rotate TestLed Right
      PortB.0 = Status.C 
      Rotate TestLed Right
      PortB.3 = Status.C 
      Rotate TestLed Right
      PortB.6 = Status.C 
      Rotate TestLed Right
      PortB.7 = Status.C
    end if
    PIR1.SSPIF=0                              'Limpio el registro de interrupt del I2C
End Sub

Do
'''''''''''''''''''''''''''''''''''''''
Loop

ahora lo compila sin errores.una duda,el slave despuès de haber recibido el dato no tendria que liberar el bus metiendo el mismo bajo?

alejandro
Participante Activo
Participante Activo

Cantidad de envíos: 41
Fecha de inscripción: 12/02/2009

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  alejandro el Dom 13 Sep 2009 - 22:27

con esta modifica(mirando el datasheet) tendria que funcionar.por lo menos me compila sin problemas.
Código:
Sub Interrupt_I2C_Serial                  'Subrutina interrupciones
    if PIR1.SSPIF=1 then
      TestLed=RxBuffer(1)                        'Recibe byte del Master
      HserPrint "Test"

      HserSend TestLed

      HserPrint "#®"

      wait 10 ms
      Rotate TestLed Right
      PortB.0 = Status.C 
      Rotate TestLed Right
      PortB.3 = Status.C 
      Rotate TestLed Right
      PortB.6 = Status.C 
      Rotate TestLed Right
      PortB.7 = Status.C
      PIR1.SSPIF=0                                'Flag de interrupt bajo,limpio el registro de interrupt del bus I2C
      SSPCON.CKP=1                            'Deja la linea SCL del bus I2C libre
    end if
End Sub

alejandro
Participante Activo
Participante Activo

Cantidad de envíos: 41
Fecha de inscripción: 12/02/2009

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  Pikitin el Lun 14 Sep 2009 - 8:32

Bueno... lo primero es que creo no has instalado totalmente el último update, en Linux hay que compilar el gcbasic.bas para tener la última versión del compilador, entonces tendrás:

Código:
Great Cow BASIC (0.9 12/8/2009)

Esta versión corrige algunos bugs de versiones anteriores, por ejemplo en algunos casos de interrupciones cuando se usan arrays ( RxBuffer() ) dentro y fuera de la interrupción.

He estado mirando la librería SSP_I2C_PicSlave.h y tienes razón... hay una rutina interrupt.

Entonces yo estaba confundido, creía que esto era la subrutina de interrupciones:

Código:
  Interrupt                                    'En caso de interrupt
  TestLed = RxBuffer(1)                        'Recibe byte del Master
  HserPrint "Test"

  HserSend TestLed

  HserPrint "#®"

  wait 10 ms
  Rotate TestLed Right
  PortB.0 = Status.C 
  Rotate TestLed Right
  PortB.3 = Status.C 
  Rotate TestLed Right
  PortB.6 = Status.C 
  Rotate TestLed Right
  PortB.7 = Status.C 


Pero nó... esta linea:
Código:
  Interrupt                                    'En caso de interrupt


Es una llamada a la subrutina interrupt que hay en la librería.

según ví en el mensaje del foro GcBasic hay que llamar a la subrutina directamente para que funcione en ese ejemplo, pero creo que eso puede ser por un problema que había con las interrupciones en algunos casos... no estoy seguro.
Pero esa librería y ese ejemplo son de hace un tiempo, habría que probar.

Entonces el código que pusiste al principio debería de compilar bién, o darte un error porque 600 baudios y reloj de 20 MHz no son compatibles en Hardware usart, para 600 baudios podrías usar 4 MHz.



Respecto a la librería:

Una cosa que no es muy buena es poner un "Sub interrupt" en una librería, porque eso puede crear conflicto si esa subrutina se crea en otro sitio, lo mejor es dejar que GcBasic gestione el tema y hacer esto:
Código:
On interrupt SSP1Ready call XXXX

Entonces GcBasic se encarga de todo y no hay conflictos.

Otra cosa no muy buena de la librería es esto:
Código:
Sub Interrupt 
    FlagCheck:
    If SSPIF Off Then goto FlagCheck
 

Porque si vás a usar otras interrupciones eso es un bucle sin fin...
Pero si es una interrupcion SSP no parece que tenga mucho sentido quedarse esperando a SSPIF.

Entonces si solo vas a usar el pic con esa librería para I2C slave no hay problema, pero si quieres hacer otras cosas entonces puede haber conflictos.

Creo que una forma mejor podría ser esta:
En la librería SSP_I2C_PicSlave.h,
En: Sub InitSSP
Cambiar esto:
Código:
    ;Setup Interrupt
    PIR1 = 0
    index = 0
    Set SSPIE On ;Enable SSP peripheral interrupt
    Set PEIE On ;Enable all peripheral interrupts
    Set GIE On ;Enable global interrupts


Por esto:
Código:
    ;Setup Interrupt
    On interrupt SSP1Ready call SlaveStatus


Y eliminar la Sub interrupt:
Código:
Sub Interrupt 
    FlagCheck:
    If SSPIF Off Then goto FlagCheck
    Set SSPIF Off ;Clear SSP flag
    SlaveStatus ;Sub to check SSP status bits
End Sub


Y Gcbasic se encarga de activar las interrupciones y de llamar a SlaveStatus cuando hay una interrupcion SSP, y tambien de borrar el flag SSPIF.

Pikitin
veterano
veterano

Cantidad de envíos: 332
Fecha de inscripción: 26/11/2008

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  Pikitin el Lun 14 Sep 2009 - 12:28

Una cosa... si instalaste gcbasic con el paquete .deb desargado de aquí entonces no tienes que compilar nada, solo descarga el paquete actiualizado e instálalo: gcbasic.deb

Si quieres conservar alguno de los archivos de la instalación anterior hazles una copia.

Pikitin
veterano
veterano

Cantidad de envíos: 332
Fecha de inscripción: 26/11/2008

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  alejandro el Lun 14 Sep 2009 - 21:27

grazias,he descargado el .deb y installado ya.
Código:
Strumento in esecuzione: gcbasic

Great Cow BASIC (0.9 12/8/2009)

Compilando /home/alejandro/Scrivania/Robot/Rover/Firmware/16F88/Control_transmiciòn.gcb ...
Programa compilado exitosamente!

Ensamblando y descargando programa ...

Fatto.


volvamos a la questiòn libreria.soy de acuerdo con las observaciones hechas.por eso he usado una llamada de interrupt fuera de la libreria
Código:
On Interrupt PORTBChange call Interrupt_I2C_Serial

no he usado un llamado con SSP1Ready pues quiero gestir todos los interrupts de las puertos B ( I2C y USART )
Código:
INTCON=b'11001000'

es verdad,la libreria USART nueva no me compila con un quarzo a 20mhz un baud a 600 (me parecia extraṅo).el dilema serà se poner un quarzo de 20 o uno de 4 mhz.
por ahora serà asi el codigo en el modulo de transmiciòn datos(16F88)
Código:
'''''''''' CONFIGURACION DEL PIC '''''''''''''''''
#chip 16f88,4
#config OSC=XT,WDT_OFF,PWRTE_ON,MCLR_ON,CP_OFF
'''''''''''''''''''''''''''''''''''''''
#include                    'libreria I2C slave
'''''''''''''''''''''''''''''''''''''''
#define Slv_Comunicacion b'00111100'            'Configuro Pic_Slave I2C_address
#define BufferLen 1                            'Cuantos byte en recepciòn para activar el interrupt
#define USART_BAUD_RATE 600                    'Configuro a 600 baud de transmiciòn

#define USART_BLOCKING
Dim RxBuffer(RxBufferSize) 
'INTCON=b'11001000'  'por ahora no los uso
ADCON1=b'00000000'
DIR PORTA b'00000'                              'Puerto A todos out
DIR PORTB b'00010110'                          'Puerto B 1/2/4 in,los demas out
PORTA=b'00000'                                  'Puerto A todos down
PORTB=b'00000000'                              'Puerto B todos down

On Interrupt PORTBChange call Interrupt_I2C_Serial

InitSSP                                        'Config. reg. SSP

InitUSART

Sub Interrupt_I2C_Serial                        'Subrutina interrupciones
    if PIR1.SSPIF=1 then
      TestLed=RxBuffer(1)                      'Recibe byte del Master
      HserPrint "Test"

      HserSend TestLed

      HserPrint "#®"

      wait 10 ms
      Rotate TestLed Right
      PortB.0 = Status.C 
      Rotate TestLed Right
      PortB.3 = Status.C 
      Rotate TestLed Right
      PortB.6 = Status.C 
      Rotate TestLed Right
      PortB.7 = Status.C
      PIR1.SSPIF=0                            'Flag de interrupt bajo
      SSPCON.CKP=1                            'Deja la linea SCL del bus I2C libre
    end if
End Sub

Do
'''''''''''
Loop

alejandro
Participante Activo
Participante Activo

Cantidad de envíos: 41
Fecha de inscripción: 12/02/2009

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  alejandro el Sáb 19 Sep 2009 - 21:26

dame un ultimo consejo,pikitin,antes de programar el microchip master.puedes controlar este codigo para escribir en una memoria 24LC256:
Código:
SUB I2C_Master_to_Memory_256(IDAddress,MemAddress,Dato)
    Start                                        '
    TxI2C(IDAddress)                              'Device ID Slave
    TxI2C(MemAddress_H)                          'Device high Address memory
    TxI2C(MemAddress)                            'Device low Address memory
    TxI2C(Dato_H)                                'Send high byte data
    TxI2C(MemAddress_H+1)                        'Device high Address memory 
    TxI2C(MemAddress+1)                          'Device low Address memory
    TxI2C(Dato)                                  'Send low byte data
    WAIT 25 ms                                    '
    Stop                                          '
END SUB

mi problema es como se dice a GCBasic que un valor es el highbyte o un lowhigh.como vez usè la dicciòn del mikrobasic.es lo mismo para GCBasic??

alejandro
Participante Activo
Participante Activo

Cantidad de envíos: 41
Fecha de inscripción: 12/02/2009

Volver arriba Ir abajo

Re: prueva con usart.h y masterI2C.h

Mensaje  Pikitin el Sáb 19 Sep 2009 - 22:34

Si... creo que así vale, lo único es que deberías definir la función así:

SUB I2C_Master_to_Memory_256(IDAddress as word, MemAddress ,Dato as word) #NR

Pero la función o subrutina TxI2C() debe aceptar solo datos de tipo byte, supongo que será así.

Lo de #NR es para ahorrar algunas lineas de código, solo es para que el compilador sepa que los argumentos no se ván a cambiar.

Pikitin
veterano
veterano

Cantidad de envíos: 332
Fecha de inscripción: 26/11/2008

Volver arriba Ir abajo

Página 1 de 2. 1, 2  Siguiente

Ver el tema anterior Ver el tema siguiente Volver arriba


Publicar nuevo tema   Responder al tema
Permiso de este foro:
No puedes responder a temas en este foro.