MCSPlus serial interface to EasyPIC6 not working?


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    You could test the board by removing the PIC and VERY VERY carefully plug a jumper wire in across the PIC TX/RX pin sockets. That will give a loop back to the PC when something is sent.

    And/or

    Program the chip, put it ina breadboard then connect to the PC. If you have the hardware.
    Use SEROUT2 with an inverted MODE then an inverter chip is not needed. Send "hello wold" like Bruce mentioned.

    Jump pins 2 and 3 at the USB/serial converter and do a loop back test.

    With out an "O" scope, write a code to send something in a loop, something long. with a second pause between sends. Connect a DVM to zero and serial pin #2 of the EasyPic and see it the is any activity from the on-board inverter chip. If the DVM fluctuates then the inverter chip is probably working.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default

    Quote Originally Posted by mackrackit View Post
    You could test the board by removing the PIC and VERY VERY carefully plug a jumper wire in across the PIC TX/RX pin sockets. That will give a loop back to the PC when something is sent.
    Tried this and got no loop back to the PC terminal display. Also put an O-scope on the jumper and see no activity when typing characters on the PC keyboard. That tells me no transmissions are reaching the RX pin on the MCU on the EasyPic6...possibly MAX202 or USB-to-serial cable bad?

    [QUOTE]
    Jump pins 2 and 3 at the USB/serial converter and do a loop back test.
    [\QUOTE]
    Did this and type characters at the PC keyboard and no loop back characters on the RX side of the terminal. Also connected an O-scope to Pin-2 of the Male DB9 connector (TX from PC) and no activity when typing characters on PC keyboard. This test tells me that the UC232A cable (USB-to-serial) is probably not wired correctly for USB to serial conversion. It still doesn't eliminate the MAX202 as the problem.

    .....Connect a DVM to zero and serial pin #2 of the EasyPic and see it the is any activity from the on-board inverter chip. If the DVM fluctuates then the inverter chip is probably working.
    By this do you mean connect the DVM to check for voltage at the MCU's RX pin socket location on the EasyPic6 with the MCU removed? I don't undersand which serial pin #2 you are referring to. It seems to me that connecting to the RX socket location would also confirm whether the inverter chip is working as long as I know the cable is good. Would appreciate your clarification on that.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    By this do you mean connect the DVM to check for voltage at the MCU's RX pin socket location on the EasyPic6 with the MCU removed? I don't undersand which serial pin #2 you are referring to. It seems to me that connecting to the RX socket location would also confirm whether the inverter chip is working as long as I know the cable is good. Would appreciate your clarification on that.
    Serial pin#2 would be the RX from the test board. I did not know that you have an O scope.
    Write a code to send serial data and connect your scope to the EasyPic board. That will tell you if anything is getting out.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default EasyPic6 serial interface works w/ mBasic but not PBP??

    Have made some progress in isolating the problem. Finally found a laptop with true serial interface so I could avoid use of USB-to-serial adapter cable. To confirm EasyPic6 interface was working I programmed a PIC16F877 chip with the standard loopback test mikroBasic code that came as sample with the EasyPic6. With this code the serial interface worked fine. This confirms there is nothing wrong with the serial interface hardware in the EasyPic6. For reference here is that simple code:
    Code:
    ' *
    ' * Project name:
    '     UART (Simple usage of UART module library functions)
    ' * Copyright:
    '     (c) Mikroelektronika, 2009.
    ' * Revision History:
    '     20080930:
    '       - initial release;
    '       - 20090720 - modified by Slavisa Zlatanovic;
    ' * Description:
    '     This code demonstrates how to use uart library routines. Upon receiving
    '     data via RS232, MCU immediately sends it back to the sender.
    ' * Test configuration:
    '     MCU:             PIC16F887
    '                      http://ww1.microchip.com/downloads/en/DeviceDoc/41291F.pdf
    '     Dev.Board:       EasyPIC6
    '                      http://www.mikroe.com/en/tools/easypic6/
    '     Oscillator:      HS, 08.0000 MHz
    '     Ext. Modules:    -
    '     SW:              mikroBasic PRO for PIC
    '                      http://www.mikroe.com/en/compilers/mikrobasic/pro/pic/
    ' * NOTES:
    '     - RX and TX UART switches on EasyPIC6 should be turned ON (SW7.1 and SW8.1).
    ' *
    
    program UART
    dim uart_rd as byte
    
    main:
      UART1_Init(9600)                     ' Initialize UART module at 9600 bps
      Delay_ms(100)                        ' Wait for UART module to stabilize
    
      UART1_Write_Text("Ready")
      UART1_Write(10)                      ' Line Feed
      UART1_Write(13)                      ' Carriage Return
    
      while (TRUE)                         ' Endless loop
        if (UART1_Data_Ready() <> 0) then  ' If data is received,
          uart_rd = UART1_Read()           ' read the received data,
          UART1_Write(uart_rd)             ' and send data via UART
        end if
      wend
    end.
    Then I programmed my 18F4550 with the below PBP code that is an adaptation I got from Mackrackit. Although the code compiles and runs, the serial interface doesn't work....no character loopbacks to Hyperterminal when typed and an oscilloscope connection to the RX pin of the 18F4550 shows nothing when characters are typed into Hyperterminal.

    I have studied the code in both cases and see little functional difference. Yet one works and the other doesn't.
    Can anyone advise me what changes to make to the PBP code to get it to work??
    Code:
    'ASM ; 18F2550/4550, 8mhz crystal
    '   __CONFIG   _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L
    '   __CONFIG   _CONFIG1H, _FOSC_HSPLL_HS_1H
    '   __CONFIG   _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
    '   __CONFIG   _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    '   __CONFIG   _CONFIG3H, _PBADEN_OFF_3H ; PortB resets as digital
    '   __CONFIG   _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    
    'ENDASM
    Include "Modedefs.Bas"
    
    DEFINE OSC 16
    
    'Register Settings
        RCSTA = $90   ' Enable serial port & continuous receive
        TXSTA = $24   ' Enable transmit, BRGH = 1
        SPBRG = 160   ' 9600 Baud @ 16MHz, -0.08%
        SPBRGH = 1
    '    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
        
        TRISB = %00000000	        ' Set PORTB to outputs as test LEDs
    INCLUDE "ALLDIGITAL.pbp"    ' Sets all registers for digital ops.
                                ' User must make sure the AllDigital.pbp file 
                                ' is in same directory location as this source
                                ' code before compiling.
        PORTB = 0               ' Turn off the LEDs
        HIGH PORTB.4            ' Blink the one Test LED as proof MCU is running
        PAUSE 500
        LOW PORTB.4
    
    ' Declare variables
    X VAR BYTE
    
    START:
        RCSTA.4 = 0 : RCSTA.4 = 1
        HSERIN [DEC X]
        PORTB.5 = 1         ' Turn on PortB.6 LED if this statement is executed
                            ' as test of receiving a character
        HSEROUT [DEC X,$d,$a]
        PORTB.6 =1          ' Turn on PortB.7 LED if this statement is executed
                            ' as test of HSEROUT having sent a character
    GOTO START

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Hint:

    There are 2 buttons available in mister-e's program ...

    DT

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Post #7 ??
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Exactly, post #7 is a good example of the same problem.

    Setting registers, instead of DEFINEs for HSERIN/OUT.

    DT

  8. #8
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Change in approach to troubleshooting UART interface

    Quote Originally Posted by Darrel Taylor View Post
    Hint:

    There are 2 buttons available in mister-e's program ...

    OK, I judge by the exchanges between DT and Mackrackit that I should have used the DEFINES button with Mister_e's PICMultiCalc. So I did. However, as a change in approach to my troubleshooting to isolate this UART problem with my PBP code, I have taken the following approach:
    1) Since I know that my EasyPic6 UART interface works with the sample loopback routine that came with it that is written in microelekBasic (see earlier post) for a 16F887 chip, I have discarded my 18F4550 chip for now to see if I can get PBPro code that is functionally identical to the microBasic routine to also work with the 16F887 chip in the EasyPic6.
    2) I have insured the _configs for my code result in the identical config bits that are generated by the microBasic code with the EasyPic6.
    3) Please see this PBPro code below and note the configs that appear to be equivalent to the microBasic version and also how I used PICMultiCalc to define the UART setup and then studied the data sheet for the 16F877 to make sure it was correct, as shown by my extensive commenting of the UART setup.
    4) I then programmed the 16F887 chip using MCSPlus, PBPro 2.6 compiler, MPASM assembler, and the PICFLASH interface to actually download the .hex file to the chip. PICFLASH also permits me to double check the configs before burning the chip.
    5) After the chip is running, I then tried HYPERTERM to type some characters over the interface. Nothing indicated on HYPERTERM in the received loopback, although this same process worked with the microBasic routine.
    6) Also tried the comm interface in MCSPlus to communicate with the running code and although it showed that the typed characters were accumulating in the TX tally at the bottom of the screen, no characters were being tallied in the RX entry. SAME PROBLEM AS OBSERVED WITH 18F4550!!
    7) In all of the above cases I assured that both the PC and the PIC ends of the EUART interface were set to COM1/9600/8bits/no parity/1 stop bit.

    The continuing failure of the PBPro code, that is as close to identical to the microBasic code as I can make it, is very frustrating to me!
    Can anyone see what is wrong with this PBPro code to cause it to continue to fail in this loopback test between a PC terminal and the running PIC??
    Code:
    ;--- if you un-comment these, you must comment the ones in the .inc file--
    ASM ; 16F887, 8mhz crystal
       __CONFIG    _CONFIG1, _HS_OSC & _WDT_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _IESO_ON & _FCMEN_ON  & _LVP_OFF & _CP_OFF & _BOR_OFF
    ENDASM
    Include "Modedefs.Bas"
    
    DEFINE OSC 8
    'Register Settings
        TRISB = %00000000	    ' Set PORTB to outputs as test LEDs
        TRISC.6 = 1             ' EUSART control will automatically reconfigure
        TRISC.7 = 1             ' these pins from input to output as needed.
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
                          ' RCSTA.7 = SPEN = 1 for Serial port enabled (configures 
                          ' RX/DT & TX/CK pins as serial port pins).
                          ' RCSTA.4 = CREN = 1 for Asynchronous Continuous Receive                  
                          ' Therefore RCSTA = %10010000 = 90h
    DEFINE HSER_TXSTA 20h ' Enable transmit, 8-bit, Asynchronous mode
                          ' TXSTA.5 = TXEN = 1 for Transmit enabled
                          ' TXSTA.4 = SYNC = 0 for Asynchronous mode
                          ' TXSTA.2 = BRGH = 0 for High Speed Asynchronous Baud Rate                               
                          ' Therefore TXSTA = %00100000 = 20h
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_SPBRG 51  ' 9600 Baud @ 8MHz, 0.16%, , 51 = 33h = %00110011
    SPBRGH = 0
    BAUDCTL.3 = 1         ' Enable 16 bit baudrate generator
        
    INCLUDE "ALLDIGITAL.pbp"    ' Sets all registers for digital ops.
                                ' User must make sure the AllDigital.pbp file 
                                ' is in same directory location as this source
                                ' code before compiling.
        PORTB = 0               ' Turn off the LEDs
        HIGH PORTB.4            ' Blink the one Test LED as proof MCU is running
        PAUSE 500               ' at tiime of power up.
        LOW PORTB.4
    
    ' Declare variables
    X VAR BYTE                  ' Variable holds received character from UART
    
    START:
        HSERIN [DEC X]
        PORTB.5 = 1         ' Turn on PortB.6 LED if this statement is executed
                            ' as a test of receiving a character.
        HSEROUT [DEC X,$d,$a]
        PORTB.6 =1          ' Turn on PortB.7 LED if this statement is executed
                            ' as a test of HSEROUT having sent a character.
    GOTO START
    Last edited by jellis00; - 11th March 2010 at 00:30. Reason: Add code

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Hang in there. We will get it working.

    But

    Where's the code?
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Please help with EDE702 - Serial to LCD interface
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th October 2008, 02:48
  2. 32-bit Quadrature Counter With Serial Interface
    By precision in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th June 2008, 02:49
  3. Serial interface with RFID reader
    By brid0030 in forum Serial
    Replies: 8
    Last Post: - 23rd January 2007, 06:23
  4. Replies: 0
    Last Post: - 25th November 2005, 14:35
  5. PIC16F877 to RFID Module Serial Interface
    By koossa in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th May 2005, 06:03

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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