Menu

PIC16F1455 Hardware Serial to PC example.

2015-05-13
2015-05-17
  • Randall Young

    Randall Young - 2015-05-13

    Hi Folks,

    I have the "Send_to_PC_Terminal_Example_via_TTL_Converter_HardwareUART" working perfectly with a PIC16F688, and a low cost CH340G USB2TLL converter, but with the PIC16F1455 at default clock setting I just get gibberish.

    very simple config...

    ; ----- Configuration
    ;#chip 16F688, 4
    ; WORKS!
    ;#config MCLRE = ON
    ;#chip 16F1455
    ; DOES NOT...
    

    Any ideas what I've done wrong?

    Best,

    Randy

     

    Last edit: Randall Young 2016-05-15
    • Anobium

      Anobium - 2015-05-13

      @Randall. I am glad to here the demos are working for you. Nice to hear this. 😃

       
  • Chuck Hellebuyck

    You need to add the 4 for 4 MHz.

    #chip 16F1455,4
    

    Otherwise it will default to the internal oscillator default setting of 500KHz on the PIC16F1455 (per the data sheet).

     
    • Anobium

      Anobium - 2015-05-13

      @Chuck. Spot on answer. I will update the Help File to explain this a little more clearly.

       
  • Randall Young

    Randall Young - 2015-05-14

    All,

    Well a continuing oddity! 4 Mhz is the one setting that doesn't output and characters at all. I know the clock is pretty complicated on the chip to support auto-tuning from USB, I'm wondering if I'm missing a config bit setting.

    Here's the slightly modified demo code:

    ; ----- Configuration
    ;#chip 16F688, 4
    ;#config MCLRE = ON
    ;exclamation is to suppress display large font on posting.
    !#chip 16F1455, 4
    
    ; ----- Define Hardware settings
    ' THIS CONFIG OF THE SERIAL PORT TO A PC TERMINAL via a TTL Converter
    ' USART settings
    #define USART_BAUD_RATE 9600
    Dir PORTc.4 Out
    Dir PORTc.3 In
    #define USART_DELAY 5 ms
    #define USART_BLOCKING
    
    ; ----- Variables
    ' No Variables specified in this example. All byte variables are defined upon use.
    
    ; ----- Main body of program commences here.
    'Message after reset
    wait 500 ms
    
    HSerPrint "First Time!"
    ' "Carriage Return"
    HSerSend 13
    ' "Line Feed"
    HSerSend 10
    
    wait 3 sec
    
    do Forever
    HSerPrint "Hello World, Randall Young"
    ' "Carriage Return"
    HSerSend 13
    ' "Line Feed"
    HSerSend 10
    wait 2 sec
    Loop
    
     

    Last edit: Randall Young 2016-05-15
  • Randall Young

    Randall Young - 2015-05-14
    ;Set up the assembler options (Chip type, clock source, other bits and pieces)
     LIST p=16F1455, r=DEC
    #include <P16F1455.inc>
    __CONFIG _CONFIG1, _MCLRE_OFF & _WDTE_OFF & _FOSC_INTOSC
    __CONFIG _CONFIG2, _LVP_OFF & _PLLEN_DISABLED & _CPUDIV_NOCLKDIV
    

    What clock speed should this result in. No PLL (not 3X) no CPUDIV. HS clock source for FOSC_INTOSC?

     

    Last edit: Randall Young 2016-03-22
  • Randall Young

    Randall Young - 2015-05-14

    All,

    The PIC16F1847 was more cooperative this morning. Running on a 18-pin PIC Demo LPC board.

    ; NOTE: remove all ! signs for cut and paste.
    
    '''A demonstration program for GCGB and GCB.
    '''--------------------------------------------------------------------------------------------------------------------------------
    '''This program sends characters from microprocess using the GCB Hardware-UART methods via a TTL converter.
    '''You have to add SCKP - Synchronous Clock Polarity Select bit acts differently depending on EUSART mode.
    '''Asynchronous mode:
    '''-1 - Transmit inverted data to the RC6/TX/CK pin; and
    '''-0 - Transmit non-inverted data to the same pin.
    '''@author  Evan R. Venn
    '''@licence GPL
    '''@version 1.0a
    '''@date    31.01.2015
    '''********************************************************************************
    
    ' ----- Alternate Configuration
    '#chip 16F688, 4
    '#config MCLRE = ON
    '#chip 16F1455, 16
    
    '----- Define Hardware settings
    
    !#chip 16F1847, 4 
    ' THIS CONFIG OF THE SERIAL PORT TO A PC TERMINAL via a TTL Converter USART settings
    
    #define USART_BAUD_RATE 9600
    
     Dir PORTB.2 Out
     Dir PORTB.1 In
    
    
    #define USART_DELAY 5 ms
    #define USART_BLOCKING
    
    'Potentiometer on AN0, Part Number DM164120-4 - PICkit 18-Pin Demo Board
    'set jumper 5, closed. Adjusting POT changes voltage reported by AN0
    
    #define POT_PORT PORTA.0
    #define POT_AN AN0
    
    
    ' ----- Variables
    ' No Variables specified in this example. All byte variables are defined upon use.
    
    ' ----- Main body of program commences here.
      'Message after reset
      wait 500 ms
    
      HSerPrint "One Time!"
       ' "Carriage Return"
       HSerSend 13
       ' "Line Feed"
       HSerSend 10
    
      wait 3 sec
    
      do Forever
       HSerPrint "Hello World, GCB & PIC16F1847"
       ' "Carriage Return"
       HSerSend 13
       ' "Line Feed"
       HSerSend 10
       wait 3 sec
    
       ;pump data out serial
       HSerPrint "Sensor Reading: "
       HSerPrint ReadAD10(POT_AN)
       HSerSend  13
       HSerSend  10
    
        wait 3 sec
      Loop
    
     

    Last edit: Randall Young 2016-03-22
  • Randall Young

    Randall Young - 2015-05-14

    Here's a screen cap of it working...

    Simple is good.

     
  • Anobium

    Anobium - 2015-05-14

    Nice job. Any idea what 'fixed' the issue?

     
  • Randall Young

    Randall Young - 2015-05-15

    A.,

    No sir I do not, my thought is/was to get it working with some flavor of PIC or another then, then take a look at the ASM file, and see if I could determine as much as possible considering the subtle differences between the PICS themselves, what the problem is. So, I have it up on '1847 but not on the '1455...

    I've had good luck on the PIC16FXXXX and Great Cow on a recent LCD project I need to post and share, the manifold and complex timing issues, just seem to work correctly on the mid-range extended products.

    R.

     

    Last edit: Randall Young 2015-05-15
  • Randall Young

    Randall Young - 2015-05-17

    All,

    Here's the source slightly adapted to work with PIC18F14k22, shows the true power of Great Cow to port across the PIC ecosystem, with just a few simple changes. Hosted on PICkit2 LPC demo board for test. Communicating to 2$ CH340G USB2TLL converter.

    '' slight modification to host PIC18F14k22
    '''@author Randall Young

    Remove all !, used to deal with display issues.

    ; --- configuration
    
    *#chip 18f14K22, 16 #config WDTEOFF , MCLREOFF , CPDOFF , BORENON, IESOOFF, FCMENOFF
    
    !#config PLLENOFF , STVRENOFF , LVPOFF
    
     ; --- uart setup, TX Data out RB.7 via Black wire
    !#define USARTBAUDRATE 57600
    
     Dir PORTB.7 Out
     Dir PORTB.5 In
    
    !#define USARTDELAY 5 ms
    !#define USARTBLOCKING
    
     'Potentiometer on AN0, Part Number DM164120-4 - PICkit 18-Pin Demo Board
     'set jumper 5, closed. Adjusting POT changes voltage reported by AN0
    
    !#define POTPORT PORTA.0
    !#define POTAN AN0
    
    
    ; ----- Variables
      ' No Variables specified in this example. All byte variables are defined upon use.
    
    ; ----- Main body of program commences here.
      'Message after reset
      wait 500 ms
    
      HSerPrint "One Time"
       ' "Carriage Return"
       HSerSend 13
       ' "Line Feed"
       HSerSend 10
    
      wait 3 sec
    
      do Forever
       HSerPrint "Hello World, GCB & PIC18F14k22"
       ' "Carriage Return"
       HSerSend 13
       ' "Line Feed"
       HSerSend 10
       wait 3 sec
    
       ;pump data out serial
       HSerPrint "Sensor Reading: "
       HSerPrint ReadAD10(POTAN)
       HSerSend  13
       HSerSend  10
    
        wait 3 sec
      Loop
    
     

    Last edit: Randall Young 2016-03-22
  • Anobium

    Anobium - 2015-05-17

    Good job. May I edit and publish?

    @Randall. I edited to add '~~~~ to your posting to correct the formatting errors. :-)

     

Log in to post a comment.