Problem with Serial Port 1 on PIC18F47K40


+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    gtv_pic
    Guest gtv_pic's Avatar

    0 Not allowed!

    Default Problem with Serial Port 1 on PIC18F47K40

    Good afternoon
    I continue with the application for the PIC18F47K40 of the previous occasion, at the moment I am having a problem with the serial port number 2 that I use to communicate by BLUETOTH. Curiously, when I define more than 530 variables in the program the serial port stops working properly, it changes the speed and sends strange characters. By simply removing the program variable, the port works correctly again.
    The port is configured like this:

    Code:
    '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    'Tipo de Procesador
    Device=18F47K40
    '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    DeclareXtal                      11  'Velocidad Real 11.059.200Hz
    DeclareOptimiser_Level            0  'Tipo Optimizacion del Compilador
    DeclareDead_Code_Remove        True  'Elimina el Codigo Sobrante
    '++++++++++++++++++++++[Genericas]++++++++++++++++++++++++++++++++++++++++++++++
    DeclareShow_System_Variables= True   'Ver Variables Internas en Simulador
    Reminders                    =False   'Anula comentarios del compilador
    DeclarePLL_Req              = True   'Multiplicar Oscilador X4.
    DeclareStack_Size           =   20   'Reserva Espacio en la Pila.
    DeclareFloat_Rounding       =False   'Redondeo en los calculos   
    Reminders                    = True   'Habilita comentarios del compilador
    DeclareWatchdog             =FALSE   'El Compilador NO pone CLRWDT 
    DeclareFSR_CONTEXT_SAVE     = True   'Guardar Variables Antes de Interupcion
    DeclareIcd_Req              = True   'Reservar Espacio para ICD2
    DeclareBootloader           = False  'No Permite la Carga del Puerto Serie
    '++++++++++++++++++++++[ComunicacionSerie Puerto 1]++++++++++++++++++++++++++++
    '                    Red RS485 de Encoder y Variador
    DeclareHserOut_Pin          PORTC.6  'Pin TX del Puerto 1
    DeclareHserIn_Pin           PORTC.7  'Pin RX del Puerto 1
    '++++++++++++++++++++++[RegistroRCSTA1]++++++++++++++++++++++++++++++++++++++++
    RCSTA1.0= 0    'RX9D = Lectura del 9 Bit 
    RCSTA1.1= 0    'OERR = Lectura de Error en Comunicacion puerto 1 
    RCSTA1.2= 0    'FERR = Lectura de Error en Comunicacion puerto 1 
    RCSTA1.3= 0    'ADDEN= Funcion Solo con 9 Bit
    RCSTA1.4= 1    'CREN  Permiso Lectura Continua del Puerto 1
    RCSTA1.5= 0    'SREN  Solo Funcionamiento en Modo Sincrono
    RCSTA1.6= 0    'ADDEN Funcionamiento a 9 Bit
    RCSTA1.7= 1    'SPEN  Puerto Serie habilitado
    '++++++++++++++++++++++[RegistroTXSTA1]++++++++++++++++++++++++++++++++++++++++
    TXSTA1.0= 0    'TX9D  9 bit a transmitir
    TXSTA1.1= 0    'TRMT  1 Indicacion en TXT cuando esta vacio Buffer de salida
    TXSTA1.2= 0    'BRGH  Dividir entre 64=0 Con 1 Divide entre 16     
    TXSTA1.3= 0    'SENDB
    TXSTA1.4= 0    'SYNC  Comunicacion ASINCRONA
    TXSTA1.5= 1    'TXEN  Transmision Habilitada
    TXSTA1.6= 0    'TX9   Transmision a 8 Bit
    TXSTA1.7= 0    'CSCR  Sin Funcion en Comunicacion Asincrona
    '++++++++++++++++++++++[RegistroBAUDCON1]++++++++++++++++++++++++++++++++++++++
    BAUDCON1=000000
    '++++++++++++++++++++++[DefinicionVelocidad Comunicacion Puerto 1]+++++++++++++
    'Ajuste Velocidad Comunicacion Puerto Serie 1 (Lectura de Encoder yMODBUS)
    'La velocidad de Comunicacion se Calcula 
    '((Frecuencia del Micro/Velocidad Deseada)/64)+1 -> TXSTA.2 sea 1
    '((frecuencia del micro/velocidad deseada)/16)+1 -> TXSTA.2 sea 0
    'Se esta multiplicando la velocidad (11059200) X 4
    'Velocidad Deseada 9600 | ((44236800 / 9600)/64)-1 = 71
    SPBRG1 =71        'Calculo de la velocidad de comunicacion
    The routine for sending characters through the serial port is:
    Code:
    
    '++++++++++++++++++++++[EnviaPor el Puerto Seria 2]++++++++++++++++++++++++++++
    Envia_PS2:
    IfP_Envio_Blue< 0 ThenP_Envio_Blue= 0
    IfPS2_TX_Vacio= 1 Then
        HSerOut2[Texto_PS[P_Envio_Blue]]
    IncP_Envio_Blue
    IfP_Envio_Blue> LTexto_PS Then
    En_Curso_Blue  = 0
    EndIf
    EndIf
    Return
    '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    How can I solve this problem?
    Thank you so much

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,374
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: Problem with Serial Port 1 on PIC18F47K40

    Are you trying to use 9600 baud?
    George.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    gtv_pic
    Guest gtv_pic's Avatar

    0 Not allowed!

    Default Re: Problem with Serial Port 1 on PIC18F47K40

    Yes, the communication speed is 9600. But the problem also happens at other speeds. While I do not use more than 530 variables it works, as soon as I define more variables it stops working.
    Thank you

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Junior Member Dave Purola's Avatar
    Join Date
    Jul 2004
    Posts
    80
    Thumbs Up
    Received: 5
    Given: 0
    Total Downloaded
    229.34 MB

    0 Not allowed!

    Default Re: Problem with Serial Port 1 on PIC18F47K40

    Have you checked the Peripheral Module Disable Register to see if it has been modified? P would also check the PPS register.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    gtv_pic
    Guest gtv_pic's Avatar

    0 Not allowed!

    Default Re: Problem with Serial Port 1 on PIC18F47K40

    I return to comment that while no more than 530 variables are defined the port works correctly, just define a variable but the port works badly, the port speed is modified and it sends strange characters.
    If I return to erase the definition of the variable, which is not being used in the program at that time, the serial port returns to work correctly at its speed and the characters sent are correct.
    Is anyone using this same micro PIC18F47K40 with the PROTON + version 3.6.2.7?
    Could it be a compiler or version problem?
    Thank you so much

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,374
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: Problem with Serial Port 1 on PIC18F47K40

    How many bytes in the 530 variables? if you swap a word (in the 530 variables) for a byte, can you add a byte variables and serial still work?
    George.

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Junior Member Dave Purola's Avatar
    Join Date
    Jul 2004
    Posts
    80
    Thumbs Up
    Received: 5
    Given: 0
    Total Downloaded
    229.34 MB

    0 Not allowed!

    Default Re: Problem with Serial Port 1 on PIC18F47K40

    I notice that you are using HSEROUT2 to send data in the lower snipit of code but, you are setting up HSEROUT in the upper snipit of code?

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    542
    Thumbs Up
    Received: 61
    Given: 0
    Total Downloaded
    503.53 MB

    0 Not allowed!

    Default Re: Problem with Serial Port 1 on PIC18F47K40

    It would also help to have the declarations for the variables TEXTO_PS and P_ENVIO_BLUE

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    gtv_pic
    Guest gtv_pic's Avatar

    0 Not allowed!

    Default Re: Problem with Serial Port 1 on PIC18F47K40

    Good
    I send you the declaration of variables of the application.
    If you need more, do not hesitate to ask.
    Thank you very much, this problem is driving me crazy, I do not know where to look
    Code:
     '++++++++++++++++++++++[VARIABLES DE LA APLICACION]+++++++++++++++++++++++++++++Dim EEprom_Ini      As Byte     ' Indica si la EPROM esta Inicializada                       
    Dim Version1        As Byte     ' Numero de Version 1
    Dim Version2        As Byte     ' Numero de Version 2
    Dim Version3        As Byte     ' Numero de Version 3
    Dim Tipo_Puerta     As Byte     ' 0 = Contaje Ascendente 1 = contaje Descendente
    Dim P_Tipo_Puerta   As Byte     ' Posible tipo de Puerta
    Dim Puerta_I        As Byte     ' 1 = Puerta Inicializada
    Dim Paso_Rutina     As Byte     ' Paso en la Rutina de Inicializacion
    
    
    
    
    Dim CNT_Analisis    As Byte     ' Numero de Ciclos entre Analisis Tendencia
    
    
    
    
    Dim INC_Encoder     As Bit      ' Indica que el Encoder esta Incrementando Valor
    Dim STOP_Encoder    As Bit      ' Indica que el ENCODER Esta Quieto
    Dim DEC_Encoder     As Bit      ' Indica que el encoder esta Decrementado Valor
    
    
    Dim Espera_Encoder  As Word     ' Ciclos de Espera en la comunicaicon Encoder
    Dim Encoder_B0      As Byte     ' Respuesta del Encoder BYTE 0
    Dim Encoder_B1      As Byte     ' Respuesta del Encoder BYTE 1
    Dim Encoder_B2      As Byte     ' Respuesta del Encoder BYTE 2
    Dim Bandera         As Byte     
    Dim CNT_Bandera     As Word
    
    
    
    
    Dim Encoder_V       As Word     ' Valor de Lectura Directa del Encoder
    Dim Evaluado_E      As Bit      ' Indicacion de Evaluada la Vuelta del Encoder
    
    
    Dim Out_Analogica   As Byte     ' Valor en % de la Salida Analogica
    Dim Aux_Out         As Word     ' Auxiliar Salida Analogica
    
    
    
    
    Dim P_Encoder       As Dword    ' Posicion del Encoder 
    Dim M_Encoder       As Word     ' Memoria de la Ultima Posicion Relativa Encoder
    Dim MA_Encoder      As Word     ' Memoria de la Ultima Posicion Absoluta Encoder
    Dim Vuelta_Encoder  As Byte     ' Numero de Vuelta del Encoder
    Dim Max_V_Encoder   As Byte       ' Calculo Max.Vueltas Encoder segun Max Encode
    Dim M_V_Encoder     As Byte     ' Memoria de la Vuelta del Encoder
    Dim T_V_Encoder     As Word     ' Tiempo Para Guardar en el EEPROM
    
    
    Dim MIN_Encoder     As Dword    ' Posicion Minima del Encoder
    Dim MAX_Encoder     As Dword    ' Posicion Maxima del Encoder
    'Dim MI1_Encoder     As Dword    ' Posicion Minima -30% del Encoder
    'Dim MA1_Encoder     As Dword   ' Posicion Maxima +30% del Encoder
    
    
    
    
    Dim D_Encoder       As Dword    ' Diferencial entre Max y Min del   Encoder
    Dim D_Salida        As Dword    ' Diferencial entre Max y Min de la Salida 
    Dim R_Calculo       As Word     ' Calculo del Diferencia de la Salida
    Dim Paso_Encoder    As Word     ' Paso de Gestion del Encoder
    Dim ERROR_Aplica    As Word     ' Codigos de Error de la Aplicacion en Binario
    Dim CODE_ENC[2]     As Byte     ' Codigo Para Enviar el Encoder
    Dim Error_LE        As Dword    ' Numero de Errores Lectura de Encoder
    Dim Ok_LE           As Dword    ' Numero de Telegramas Correctos de Encoder
    Dim Error_Comu      As Word     ' Numero de Errores Continuos de Comunicacion
    
    
    Dim Aux_Calculo     As Dword    ' Auxiliar de Calculo
    
    
    Dim AUX_C_E         As Word     ' Auxiliar de Calculo del Encoder
    
    
    
    
    Dim CNT_2P          As Word     ' Contador Dos Pulsadores Pulsados
    
    
    
    
    Dim FLASH1          As Bit      ' Intermitente Rapido
    Dim Flash2          As Bit      ' Intermitente Normal
    Dim Flash3          As Bit      ' Intermitente Lento
    
    
    Dim Espera          As Dword    ' Contador de Espera
    
    
    Dim CNT_Ciclos      As Word     ' Contador de Ciclos
    Dim CNT_C_Blue      As Byte
    
    
    
    
    Dim Texto_PS        As String * 120
    Dim Texto_PS1       As String * 10
    Dim LTexto_PS       As Byte     ' Largo del Texto a Enviar por Bluetooth
    
    
    
    
    
    
    
    
    Dim P_Envio_Blue    As Byte     ' Posicion de Envio del BlueTooth
    Dim En_Curso_Blue   As Bit      ' Indicacion de En Curso Envio del BLUETOOTH
    Dim S_BLUETOOTH     As Byte     ' Seleccion que Enviar por Bluetooth
    
    
    
    
    Dim Digito_7Seg     As Byte     ' Digito a Presentar en el 7 Segmentos
    Dim N_Digito_7Seg   As Byte     ' Numero de Digito a Presental en el 7 Segmentos
    
    
    
    
    '++++++++++++++++++++++[Calculo del CRC]++++++++++++++++++++++++++++++++++++++++
    Dim Crcx                As Word             ' Calculo del CRC
    Dim Car                 As Byte             ' Caracter que se Procesa
    Dim Bitt                As Byte             ' Bit del Caracter que se Procesa
    Dim Flag                As Bit              ' Calculo del CRC
    Dim CRC [2]             As Byte             ' CRC de Entradas
    Dim CRCs[2]             As Byte             ' CRC de Salida  
    Dim L_Telegrama         As Byte             ' Numero Caracteres Telegrama PS1
    Dim Buffer1             As String * 255     ' Buffer Caracteres TX PS1
    
    
    
    
    Dim N_Arranques     As Dword
    
    
    
    
    '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    '
    '
    '++++++++++++++++++++++[SIMBOLOS DE LA APLICACION]++++++++++++++++++++++++++++++
    Symbol LED_OK           =  PORTA.4      ' Led OK de la Placa
    Symbol LED_1            =  PORTB.3      ' Led 1 del Micro
    Symbol LED_2            =  PORTB.4      ' Led 2 del Micro
    
    
    Symbol Pulsador_1       =  PORTD.6      ' Pulsador 1 de Placa
    Symbol Pulsador_2       =  PORTD.7      ' Pulsador 2 de Placa
    
    
    Symbol FC_Cerrada       =  PORTA.5      ' Indicacion Puerta Cerrada
    Symbol FC_Abierta       =  PORTE.0      ' Indicacion Puerta Abierta
    Symbol P_Abrir          =  PORTE.1      ' Indicacion Pulsador Abrir
    Symbol P_Cerrar         =  PORTE.2      ' Indicacion Pulsador Cerrar
    Symbol P_Parada         =  PORTC.0      ' Indicacion Puerta Parada
    Symbol Fotocelula       =  PORTD.5      ' Indicacion Fotocelula
                                 
    Symbol S_Seguridad      =  PORTD.3      ' Salida  de Seguridad del Encoder
    Symbol E_Seguridad      =  PORTD.1      ' Entrada de Seguridad del Encoder
    Symbol L_Seguridad      =  PORTD.3      ' Limite de Seguridad del Encoder
    
    
    Symbol KEY_BLUETOOTH    =  PORTD.2      ' SALIDA para el  BLUETOOTH
    Symbol I_BLUETOOTH      =  PORTB.5      ' Entrada para el BLUETOOTH
    
    
    Symbol Enabled_TX_485   =  PORTC.3     ' Permiso Trasnmision para el RS485
    
    
    Symbol Rele_Abrir       =  PORTC.4     ' Rele Abrir
    Symbol Rele_Cerrar      =  PORTC.5     ' Rele Cerrar
    Symbol Rele_Freno       =  PORTD.4     ' Rele Freno
                  
    ' Simboloa del Puerto Serie 1
    Symbol FERR1            = RC1STA.2
    Symbol CERR1            = RC1STA.1
    Symbol PS1_TX_Vacio     = TXSTA1.1
    ' Simboloa del Puerto Serie 2
    Symbol FERR2            = RC2STA.2
    Symbol CERR2            = RC2STA.1
    Symbol PS2_TX_Vacio     = TXSTA2.1    
                  
                  
                               
    ' Son cosntantes sin Definir asi que las Asigno a Variable
    Dim    Seg_a            As Bit          ' Segmento a
    Dim    Seg_b            As Bit          ' Segmento b
    Dim    Seg_c            As Bit          ' Segmento c
    Dim    Seg_d            As Bit          ' Segmento d
    Dim    Seg_e            As Bit          ' Segmento e
    Dim    Seg_f            As Bit          ' Segmento f
    Dim    Seg_g            As Bit          ' Segmento g
    Dim    Seg_dp           As Bit          ' Segmento dp. Punto Decimal
    Last edited by gtv_pic; 9th December 2018 at 16:30.

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Laptop without serial port
    By mnementh in forum Proton Development Board
    Replies: 11
    Last Post: 21st May 2008, 00:49
  2. Serial Data out of the PC serial Port
    By Harrison in forum Labcenter Proteus VSM
    Replies: 7
    Last Post: 6th March 2008, 18:12
  3. New problem serial port
    By gtv_pic in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 31st August 2006, 10:56
  4. [SOLVED !] bluettoth serial port
    By pepito in forum Mecanique - IDE
    Replies: 2
    Last Post: 5th May 2006, 09:31
  5. [SOLVED !] Second HS serial port.
    By speeder in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 12th January 2006, 04:13

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts