Serout/serout2


Closed Thread
Results 1 to 11 of 11

Thread: Serout/serout2

Hybrid View

  1. #1

    Default SEROUT re

    If the MCS config. options list is correct regarding the device setup, why should it be necessary to add the redundant assembly code? Which has last say, the actual program code or the IDE controlling the up load. Never the less when I try adding the device config lines as they are presented from the site all I get is:
    ERROR 16F628~5 ASM 45:[235] opcode expected instead of 'PIC16f628'

    If I take the 16f628 out of the line, the error code changes to:
    ERROR 16F628~ 5 ASM 45: [235] opcode expected instead of intc_osc_noclkout

    The basic questions are:
    What am I doing wrong regarding the code? If the program is OK,
    Is it a hardware or sofware problem? Other options woulld be to: try another chip or install PBP into the MPLAB. I'm not ready for the latter. I guess my frustration is showing. JS

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    O.K. Let's try something first. A very simple test program test to send a text string to your PC via COM port. You'll use the MCS serial communicator (F4 then F9 to connect to the PORT)

    Code:
        '
        '    Hardware configuration
        '    ======================
        @ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _LVP_OFF & _BODEN_ON 
             ' Internal Oscillator
             ' Disable watch dog timer
             ' Enable power up timer
             ' Disable MCLR pin
             ' Disable low voltage programming
             ' Enable brown out detect         
    
        TRISB=0                            ' PORTB : output to all i/o
             
        '                      
        '    Hardware connection
        '    ===================
        SerPin         var PORTB.4         ' Serial data out connected via 1K resistor
                                           ' to PIN 2 of PC DB9 connector
                                           ' Don't forget the GND :o)
        
        '
        '    Serial Communication definition
        '    ===============================
        BAUD           con 16780           ' 2400 Baud, Driven inverted, No Parity          
    
        '
        '    Software/Hardware initialisation
        '    ================================
        serpin = 0                         ' Set Serial data out to normal state  
        pause 100                          ' safe settle time
        
        '
        '    ////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\        
        '
        '                             Program Start Here                               
        '
        '    ////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\        
        '    
    START:
        SEROUT2 SERPIN,BAUD,["PC COMMUNICATION TEST",13,10]
        PAUSE 500
        GOTO START
    if you use PM as assembler, use the following config fuses OR set them manually.
    Code:
        '
        '    Hardware configuration
        '    ======================
        asm     
            DEVICE PIC16F628, INTRC_OSC_NOCLKOUT ; Internal Oscillator
            DEVICE PIC16F628, WDT_OFF            ; Disable watch dog timer
            DEVICE PIC16F628, PWRT_ON            ; Enable power up timer
            DEVICE PIC16F628, MCLR_OFF           ; Disable MCLR pin
            DEVICE PIC16F628, BOD_ON             ; Enable brown out detect    
            DEVICE PIC16F628, LVP_OFF            ; Disable low voltage programming
            ENDASM
    is the above work?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3

    Thumbs up SEROUT re

    Mr.E,
    As you suggested, I ran the communications test program through the serial port via the MCS and everything was right on. It filled up the receive window with the expected text. Without a scope check on RB4 when hooked up to the H-bridge I don't think I can do to much more with this, other than fine tuning the DEFINE CHAR_PACING ? If you have any other ideas on what to try I'll give them a go. Thanks for lifting the bar to the next level. JS

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    well hard to say if the CHAR_PACING is the solution to this. It's possible that the internal OSC is not too much accurate for a proper serial comm to your device. mmm, can you try to use an external 4MHZ crystal (not ceramic resonator) first?

    How about DEBUG function ?

    How about the internal USART (HSERIN/HSEROUT)?

    maybe.. maybe...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5

    Cool SEROUT re

    Quick follow up on the H-bridge. I'm now running an external 14 Pin DIP clock at 4 Mhz.,100ppm. I ran the communications test program by adding the folowing ASM
    DEVICE PIC16F628, XT_OSC
    DEVICE PIC16F628, CPD_OFF
    DEVICE PIC16F628, PROTECT_OFF
    This makes the MCS come up right on without double checking everything.
    The comm. test ran perfectly. The motor did the same routine....a little hum. I ran the motor supply volts up some to the bridge and one time it picked up one of the speeds, ? go figure? ,nothing after this one time event. I added character pacing of 1000, no change. I think I'll experiment with some different pacing values before moving into the USART. For those out there having unusal wierd problems with compiler errors when their code is exactly the same as a previous good program, I have found that there may be a glitch between going from one computer to another (different operating systems) with files on a 3 1/2 floppy. Maybe I have some bad disks although the formats were clean. Is the latest version of MCS OK or does the BETA need a little more BETTER? Later JS

Similar Threads

  1. Serout/Serout2 on pin RC6
    By Ioannis in forum Serial
    Replies: 14
    Last Post: - 12th December 2008, 19:06
  2. Serout/Serout2 and PIC18F97J60 (100 pin)
    By mikebar in forum Serial
    Replies: 10
    Last Post: - 20th May 2008, 04:16

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