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

    Below are the setting for 9600 baud at 16MHz
    Code:
    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $20 ' Enable transmit, BRGH = 0
    SPBRG = 25  ' 9600 Baud @ 0.16%
    You have the ones in your code commented out.

    Run this code and type numbers at the keyboard.
    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
    DEFINE OSC 16
    
    ADCON1 = 15		' All I/O pins digital
    
    X VAR BYTE
        START:
        RCSTA.4 = 0 : RCSTA.4 = 1
        RCSTA=$90:TXSTA=$20:SPBRG=25
        HSERIN [DEC X]
        HSEROUT [DEC X,$d,$a]
    GOTO START
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    Set SW7.1 on for RC7 = RX and SW8.1 on for RC6 - TX
    On SW7 & SW8 flip everything else to the OFF position leaving only switches #8 on each one ON. Does it work?

    In: http://www.mikroe.com/pdf/easypic6/e...anual_v100.pdf the photo in Figure 6-1 shows both DIP
    switches for RC6 & RC7 on switch positions #1.

    And just below this in Figure 6-2 they show RC6 & RC7 on DIP switch positions #8. Which is right?
    Last edited by Bruce; - 5th March 2010 at 04:31. Reason: Which is right?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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

    Default Tried both ways...I think 1st photo is correct.

    Quote Originally Posted by Bruce View Post
    On SW7 & SW8 flip everything else to the OFF position leaving only switches #8 on each one ON. Does it work?

    In: http://www.mikroe.com/pdf/easypic6/e...anual_v100.pdf the photo in Figure 6-1 shows both DIP
    switches for RC6 & RC7 on switch positions #1.

    And just below this in Figure 6-2 they show RC6 & RC7 on DIP switch positions #8. Which is right?
    Tried it both ways, Bruce, while running Mackrackit's code as I modified it above. And as I said in above post to him, no LED test lights turned on, indicating the HSERIN and HSEROUT statements never executed....meaning no receipt of the character I typed on the keboard by the HSERIN.

    Any other ideas?

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    I always include DEFINE HSER_CLROERR 1 if using HSERIN just to be sure it' never locked up on me, but I'm not sure that's the problem.

    Try sending first. Something like HSEROUT ["Hello World",13,10] to MCS terminal. If this doesn't work, then try using SEROUT2 PORTC.6,84,["Hello World",13,10].

    If you get nothing on screen, I would check my connection from RC6 to the PC side of the MAX IC, serial cable, etc.

    If you have an O-Scope set it in a continuous HSEROUT loop while watching the MAX TX out pin to PC.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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

    Default

    I will try those ideas, Bruce.

    Got to wondering if the MCU was actually running. I can see from the PRG light on the EasyPic6 it is getting programmed but in previous code didn't have any way to confirm it was actually running....if it weren't that could explain why the test LEDs didn't light in previous post and also possibly why the HSERIN and HSEROUT statement aren't executing...hence no communications.
    I inserted a blinking LED in the loop in the below version and when I run it, it doesn't blink...indicating the MCU is not running!! Now I don't know what to do to make the MCU run.?????
    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"
    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.
    
    DEFINE OSC 16
    TRISB = %00001111	' Set PORTB.4,5,6,7 to outputs as test LEDs
    
    ADCON1 = 15		' All I/O pins digital
        PORTB.5 = 0
        PORTB.6 = 0                 ' Turn off the LEDs
        PORTB.7 = 0
    
    
    X VAR BYTE
    
        START:
        PORTB.5 = 1         ' Blink LED as test that MCU is running
        RCSTA.4 = 0 : RCSTA.4 = 1
        RCSTA=$90:TXSTA=$20:SPBRG=25
        HSERIN [DEC X]
        PORTB.6 = 1         ' Turn on PortB.6 LED if this statement is executed
                            ' as test of receiving a character
        HSEROUT [DEC X,$d,$a]
        PORTB.7 =1          ' Turn on PortB.7 LED if this statement is executed
                            ' as test of HSEROUT having sent a character
        PORTB.5 = 0
    GOTO START

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    I've never used this board, but it looks like there's a ton of jumpers on there. And if you're not getting even an LED to blink, I would bet you're just missing a jumper setting!

    Might even try replacing the PIC.

    Is the POWER LED ON?
    Last edited by Bruce; - 5th March 2010 at 05:59.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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

    Default

    Quote Originally Posted by Bruce View Post
    I've never used this board, but it looks like there's a ton of jumpers on there. And if you're not getting even an LED to blink, I would bet you're just missing a jumper setting!

    Might even try replacing the PIC.
    I just burned a test program into the chip via same programming path I've been using that is a "blinky LED". It works fine. This tells me that at least the MCU chip will run and is OK. However, from what I saw that I described in my previous post, the serial interface code is NOT running in the MCU. Don't know why it would run with one program and not the other???

    Is the POWER LED ON?
    [/QUOTE] Yes it is.

    I just was wondering if it might be the USB to Serial converter cable I have to use because the Laptop I am using doesn't have a true serial (RS232) interface connector. I am using an ATEN UC232A USB-to-serial converter cable that connects to the DB9 connector on the EasyPic6 serial interface. It has a light built in to the serial end of the cable that comes on when the TX and RX switch selections are correct on SW7 and SW9 and the MCU is powered up. I have heard before that some of these USB to serial cables don't always work with some serial interfaces. Have any ideas about this one?
    If that isn't it, then it is looking more and more like a failure in one of the compnents in the EasyPic6 serial circuit.....possibly the MAX202 they use...just don't know how to text the circuit to see if it is a H/W failure.
    I'm really running out of ideas.
    Last edited by jellis00; - 5th March 2010 at 06:39.

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

    Default Ran your code

    Quote Originally Posted by mackrackit View Post
    Below are the setting for 9600 baud at 16MHz
    Code:
    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $20 ' Enable transmit, BRGH = 0
    SPBRG = 25  ' 9600 Baud @ 0.16%
    You have the ones in your code commented out.

    Run this code and type numbers at the keyboard.
    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
    DEFINE OSC 16
    
    ADCON1 = 15		' All I/O pins digital
    PORTB.6 = 0                 ' Turn off the LEDs PORTB.7 = 0
    
    X VAR BYTE
        START:
        RCSTA.4 = 0 : RCSTA.4 = 1
        RCSTA=$90:TXSTA=$20:SPBRG=25
        HSERIN [DEC X]
        HSEROUT [DEC X,$d,$a]
    GOTO START
    Mackrackit, I created a .pbp file from your above code with a slight modification where I inserted a LED turn on just after the HSERIN and just after the HSEROUT statements. See the code below. Then when running the code and typing characters on the keyboard I do not see these respective lights come on in the EasyPic6. This says the HSERIN and the HSEROUT statements are never executing when the code is running and the PC terminal is connected. This implies a hardware failure somwhere in the EasyPic6 serial interface circuitry....do you agree???
    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
    DEFINE OSC 16
    TRISB = %00001111	' Set PORTB.4,5,6,7 to outputs as test LEDs
    
    ADCON1 = 15		' All I/O pins digital
        PORTB.6 = 0                 ' Turn off the LEDs
        PORTB.7 = 0
    
    X VAR BYTE
        START:
        RCSTA.4 = 0 : RCSTA.4 = 1
        RCSTA=$90:TXSTA=$20:SPBRG=25
        HSERIN [DEC X]
        PORTB.6 = 1         ' Turn on PortB.6 LED if this statement is executed
                            ' as test of receiving a character
        HSEROUT [DEC X,$d,$a]
        PORTB.7 =1          ' Turn on PortB.7 LED if this statement is executed
                            ' as test of HSEROUT having sent a character
    GOTO START
    Last edited by jellis00; - 5th March 2010 at 05:16. Reason: Add the code

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, 03:48
  2. 32-bit Quadrature Counter With Serial Interface
    By precision in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th June 2008, 03:49
  3. Serial interface with RFID reader
    By brid0030 in forum Serial
    Replies: 8
    Last Post: - 23rd January 2007, 07:23
  4. Replies: 0
    Last Post: - 25th November 2005, 15:35
  5. PIC16F877 to RFID Module Serial Interface
    By koossa in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th May 2005, 07: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