Finally trying to do some serial- Won't compile :(


Closed Thread
Results 1 to 17 of 17
  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Unhappy Finally trying to do some serial- Won't compile :(

    using 16F1947
    PBP2.6A
    MPLAB 8.53
    and heres the big code:
    Code:
    INCLUDE "MODEDEFS.BAS"
    
    DEFINE HSER2_RCSTA  90H
    DEFINE HSER2_TXSTA  20H
    DEFINE HSER2_BAUD   2400
    DEFINE HSER2_CLROERR 1
    
     LED0 = 0
    START:
     HSERIN2 [WAIT("S"),SPEED]
     LED0 = 1
     HSEROUT2 [SPEED]
     'HESRIN2 [WAIT("G")]
     GOTO START
    Heres the errors:
    Code:
    ERROR: Macro HSERIN2WAIT?CL not found in macro file.
    ERROR: Macro HSERIN2?B not found in macro file.
    ERROR: Macro HSEROUT2?B not found in macro file.

    edit: forgot to mention if I take out the "2's" as if using EUSART1, it will compile as is
    Last edited by cncmachineguy; - 25th January 2011 at 02:58. Reason: added
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    There is nothing wrong with your code, it is something in PBP.
    You code works with other two port chips.

    Contact Melabs and ask for Darrel
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    BTW...

    INCLUDE "MODEDEFS.BAS"
    is not needed.

    And your code only worked with the other chips when the VARs were defined.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    There is nothing wrong with your code, it is something in PBP.
    You code works with other two port chips.

    Contact Melabs and ask for Darrel
    Leave it to me to find a problem. OK I will attempt to contact them/him

    Quote Originally Posted by mackrackit View Post
    BTW...

    INCLUDE "MODEDEFS.BAS"
    is not needed.
    I didn't think so, but I put it in when it didn't work. Seemed to be the "regular" answer. I will take it out.
    And your code only worked with the other chips when the VARs were defined.
    Heres the full code:
    Code:
    ' Name        : Interface card.pbp
    ' Compiler    : PICBASIC PRO Compiler 2.6A
    ' Assembler   : MPASM
    ' Target PIC  : 16F1947
    ' Hardware    : PIMill Interface
    ' Oscillator  : internal
    ' Keywords    :
    ' Description : PICBASIC PRO program to interface parallel port
    ' to 4 stepper drives and limit switches
    '
    INCLUDE "MODEDEFS.BAS"
    '
    '
    '
    ' Configure ports
    '
    '
    ANSELA = %00000000  'port A all digital
    ANSELE = %00000000  'port E all digital
    ANSELF = %00000000  'port F all digital
    ANSELG = %00000000  'port G all digital
    
    CM1CON0 = %00000000  'No comparaters
    CM1CON1 = %00000000
    CM2CON0 = %00000000
    CM2CON1 = %00000000
    
    ' preload latches before setting direction
    LATB = %00000000
    LATC = %00000000
    LATD = %00010000 'LED's 0 for red, 1 FOR GREEN should start red
    LATF = %00001111 ' low nibble is drive enable. 1 disables
    LATG = %00000000
    
    ' I/O direction
    
    TRISA = %11111111'step and dir inputs
    TRISB = %11000001'7-0 icsp,icsp,h4o,h3o,h2o,h1o,estopO,enable In
    TRISC = %00000000'step and dir outputs
    TRISD = %01100000'led6,i2c,i2c,led5,led4,led3,led2,led1
    TRISE = %11111111'ls4,lsh4.ls3,lsh3,ls2,lsh2,ls1,lsh1
    TRISF = %10010000'manual ready,servo out,dac out,flood input,4en,3en,2en,1en
    TRISG = %11100111'x,x,icsp/mclr,rly2,rly1,Rx2,Tx2,SPINDLE ON
    
    
    
    
    'REMOVE THIS LINE IF NOT SETTING THE CONFIGS IN CODE SPACE
    @ __config _CONFIG1,_FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
    @ __config _CONFIG2,_WRT_OFF & _VCAPEN_OFF & _PLLEN_ON & _STVREN_OFF & _BORV_25 & _LVP_OFF
    
    'Internal osc setup
    OSCCON = %11110000 'clock is 8 meg. turn on PLL for 32 meg clock
    DEFINE OSC 32
    DEFINE NO_CLRWDT 1
    
    'Variables
    'Port assignments
    '------------------port B
    ENALL   VAR PORTB.0
    ESTOPO  VAR PORTB.1
    HO1     VAR PORTB.2
    HO2     VAR PORTB.3
    HO3     VAR PORTB.4
    HO4     VAR PORTB.5
    '------------------port D
    LED0    VAR PORTD.0
    LED1    VAR PORTD.1
    LED2    VAR PORTD.2
    LED3    VAR PORTD.3
    LED4    VAR PORTD.4
    LED5    VAR PORTD.7
    '------------------port F
    EN1     VAR PORTF.0
    EN2     VAR PORTF.1
    EN3     VAR PORTF.2
    EN4     VAR PORTF.3
    DIGIN   VAR PORTF.5
    SERVO   VAR PORTF.6
    MANREADY VAR PORTF.7
    '------------------port G
    SPINON  VAR PORTG.0
    RLY1    VAR PORTG.3
    RLY2    VAR PORTG.4
    '---------------------Bytes
    CNT     VAR BYTE
    FRAMECT VAR BYTE
    POS     VAR BYTE
    MYFLAGS VAR BYTE
    PRELOAD VAR BYTE
    SPEED   VAR BYTE
    DUMRUN  VAR BYTE
    '---------------------Bits
    COUNTUP VAR MYFLAGS.0
    COUNTDN VAR MYFLAGS.1
    MS      VAR MYFLAGS.2
    LIMIT   VAR MYFLAGS.3
    DRIVEON VAR MYFLAGS.4
    HOMED   VAR MYFLAGS.5
    READYSW VAR MYFLAGS.6
    '---------------------INIT VARIABLE VALUE
    READYSW = 0
    HO1 = 1
    HO2 = 1
    HO3 = 1
    HO4 = 1
    COUNTUP = 1
    COUNTDN = 0
    POS = 127
    FRAMECT = 0
    MS = 0
    HOMED = 0
    CNT = 0
    SPEED = 0
    PRELOAD =  39 'PRELOAD 39 PR = NUMBER OF CYCLES-1
    
    DEFINE HSER2_RCSTA  90H
    DEFINE HSER2_TXSTA  20H
    DEFINE HSER2_BAUD   2400
    DEFINE HSER2_CLROERR 1
    
     LED0 = 0
    START:
     HSERIN2 [SPEED]
     LED0 = 1
     HSEROUT2 [SPEED]
     'HESRIN2 [WAIT("G")]
     GOTO START
    Just posting for the VAR's sake.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    From what I see in the .LIB file, it seems the 2nd USART is not implement yet in any 16F... PIC(tm)
    Steve

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

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Seems like I missed that declaration of limitation when deciding to buy.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    I, you or some, could copy paste HSERIN macros (and some other compiler directives), modify it, include them in the .LIB so you have a "fully workable" 2nd USART... but it belongs to Melabs to fix

    Nothing stop you to implement a home-made one though...
    Steve

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

  8. #8
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Modifying .LIB files works well, but it is a mixed blessing when MELabs releases a new version. You want the new features, but you have to be really careful to move your changes into the new library. When that time comes, I highly recommend the program ARAXIS MERGE.
    Charles Linquist

  9. #9
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Thanks for the help guys. I looked at the LIB files and I don't want to mess with them. I will try my luck with support, until then I guess I will just do it "long hand". It seems to me the advantage of HSERIN/HSEROUT is easy array TX/RX and data formating.

    Can anyone confirm this?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    true. do you need all features, high baudrate and interupts? In meantime can DEBUG/SERIN be enough?
    Steve

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

  11. #11
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    I am not sure what "all features" are. No I don't need high Baud or interupts. I DO need to use the 2nd UART and not the 1st. I am trying to play with SERxxx2 now just to establish board function and communcation with PC. When I have that working, I will move on to the hardware UART. I am hoping by then maybe Melabs will have an answer as to fixing the omission or not. From there I will decide how I want to code the hardware UART based on their answer. Right now I am feeling like a "PBP talking to the registers" is going to be the answer. Thats still a tiny bit simpler then writing it in ASM.

    Or I will come up with an "include" file so I can use it like HSERxxx. maybe I'll call it BSHIN and BSHOUT!
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  12. #12
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Sounds like The hardware serial port 2 should be on this bugs list, as well as HPWM for the chips that have multiple HPWM but can't use the command. At least with HPWM you can easily control it manually though.

    http://melabs.com/support/pbpissues.htm
    http://www.scalerobotics.com

  13. #13
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Well I heard back from Melab. They confirmed the 2nd Usart has been overlooked in the 16F devices. They said there may still be time to include it in the 2.6B patch. But not sure just yet. So for me, I guess only time will tell if they fix it before I need it. And with the way I work, it may take me a month to need it, or could be tomorrow - LOL
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    That's what happen when the PCB is design first

    Wish you a month before needing it
    Steve

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

  15. #15
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cncmachineguy View Post
    Well I heard back from Melab. They confirmed the 2nd Usart has been overlooked in the 16F devices.
    Or, to throw a really big wrench in, sounds like you could change to a PIC18F6722 or similar PIC18 device, and have two serial ports.

  16. #16
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default You guys are funny!

    @ steve, somewhere I missed the part about designing hardware around the UNKNOWN compiler limitations instead of the hardware requirements.

    @walter, I will look at those chips and see if I want to change.

    Now don't get me wrong, this is no show stopper by any means. Simply a matter of (in)convience
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    It's a hidden free feature not much

    I feel your pain, I think we all hit one of those feature once in a while. At least Melabs are aware and they have it listed, so it's all good. Just need to wait a lil bit.

    Fortunately, in your case, "this is no show stopper by any means".
    Steve

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

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