MCSPlus serial interface to EasyPIC6 not working?


Closed Thread
Results 1 to 34 of 34

Hybrid View

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

    Default

    Hint:

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

    DT

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

    Default

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

  3. #3
    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

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

    Default

    Post #7 should have the correct settings.

    What is wrong with setting registers? I do this at times when I need to change the baud rate on the fly.
    Dave
    Always wear safety glasses while programming.

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

    Default

    Hmmm, suddenly I was in a world where everything was reversed.

    Such as using defines when reading RCREG.
    Turned into setting regs when using HSERIN.

    Strange ... very strange ...
    OOPS
    DT

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Hmmm, suddenly I was in a world where everything was reversed.

    Such as using defines when reading RCREG.
    Turned into setting regs when using HSERIN.

    Strange ... very strange ...
    OOPS
    I'd like one of those too, please

    Ioannis
    Last edited by Ioannis; - 11th March 2010 at 08:26.

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

    Default

    I have pins
    RC7 connected to MAX232 pin 12
    RC6 connected to MAX232 pin 11

    MAX232 pin 13 connected to DB9 pin3
    MAX232 pin 14 connected to DB9 pin2

    Both of the codes below do the same thing. I do not have an EasyPic board but this has been tested on breadboard.
    Code:
    '16F887 HERSIN/OUT
       @ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
       OSCCON = %01110000
       DEFINE OSC 8
       DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
       DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
       DEFINE HSER_CLROERR 1 ' Clear overflow automatically
       DEFINE HSER_SPBRG 51  ' 9600 Baud @ SPBRGH = 0      25 FOR 4MHz
       BAUDCTL.3 = 1         ' Enable 16 bit baudrate generator
       X    VAR BYTE
       RUN:
       HSERIN [X]
       HSEROUT [X,$d,$a]
       GOTO RUN
    Code:
    '16F887 HERSIN/OUT    #2
       @ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
       OSCCON = %01110000
       BAUDCTL.3 = 1         
       X    VAR BYTE
       RUN:
       RCSTA=$90:TXSTA=$20:SPBRG=51
       HSERIN [X]
       RCSTA.4 = 0 : RCSTA.4 = 1
       HSEROUT [X,$d,$a]
       GOTO RUN
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    May 2008
    Location
    Italy
    Posts
    825

    Default

    Did you check the cable connecting the two units? There is the possibility that you have Rx connected to Rx. See the attached picture.

    Al.
    Attached Images Attached Images  
    All progress began with an idea

  9. #9
    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

  10. #10
    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.

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

    Default Here is the code for previous post

    Here is the code for previous post

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