can buss macro compiler problem


+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 25

Thread: can buss macro compiler problem2484 days old

  1. #1
    timpainter
    Guest timpainter's Avatar

    0 Not allowed!

    Default can buss macro compiler problem

    Hi I an having a problem using can_macro.pbp file 26 may 2011 on compile i have 3 errors ASM error 122 AS4562 illegal optcode ASM error 128 AS4571 missing arguments ASM error 149 AS4574 directive only allowed when generating an object file proton ide 2.0.1.2 compiler 3.5.5.4 I have no understanding of these errors any advice would be most greatfully recived Thanks Tim Painter
    PS i have limited exspiriance with pic basic and proton ide

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,323
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    802.03 MB

    0 Not allowed!

    Default Re: can buss macro compiler problem

    Hi Tim,
    As I pointed out in the email, you need to post the code otherwise the errors are meaningless.

    Regards,
    Bob

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    timpainter
    Guest timpainter's Avatar

    0 Not allowed!

    Default Re: can buss macro compiler problem

    Hi
    the code i an using is can_simple_demo_1_14.bas
    I think my problems are with the compiler/proton ide
    if i attempt to compile as is i get errors like variable ( CANSetOperationMode [CAN_OP_MODE_CONFIG,NO])not found
    so presumably the precompiler did not do its job?
    library manager seems to be working all macros show up including "CAN_LIBRARY_1_4.pbp" and message saying connected.
    by adding the line after, Include "18F458_CONFIG.INC"
    Include "CAN_LIBRARY_1_4.pbp"
    this takes me a little further down the line but
    reults in errors like colon after goto lable and general sintax errors in CAN_LIBRARY_1_4.pbp
    I think i may be making a fundermental mistake some where but cant see the wood becuse of the trees!
    when i find out how to post code in a window i will do so

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #4
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,323
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    802.03 MB

    0 Not allowed!

    Default Re: can buss macro compiler problem

    Hi,
    OK, I have that file so will look at it as soon as I can, first off though, it does not sound like you have the library installed correctly.
    It also seems like you have not got the latest libray file as there was an issue with colons, not sure what happened there as it was a long time ago.
    The one on the wiki should be correct but in case it is not I have attached the one I am using, it has the same filename as I had a problem with the library manager when I changed it (I do not do enough to know what I did wrong so left the name the same.
    You still might have problems with that though, I have had a lot of issues so I am going right through it which will take a while, I am not sure if there is something which latest compiler code does not like or something in some modifications I have done (more likely) which are the issue so I have decided to start from scratch again to make sure it is reliable.

    Regards,
    Bob

    CANLibrary.zip
    Last edited by RGV250; 27th January 2013 at 13:22.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #5
    timpainter
    Guest timpainter's Avatar

    0 Not allowed!

    Default Re: can buss macro compiler problem

    Hi
    Thanks for the reply,
    I will try re installing the library manager.
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #6
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,154
    Thumbs Up
    Received: 95
    Given: 1
    Total Downloaded
    2.59 GB

    0 Not allowed!

    Default Re: can buss macro compiler problem

    I don't think it is a Library Manager issue it sounds like the same problem with colons being left at the end of some lines.
    JohnB

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #7
    timpainter
    Guest timpainter's Avatar

    0 Not allowed!

    Default Re: can buss macro compiler problem

    Hi
    Hi
    finaly got "simple "demo to compile, I changed precompiler options to skip lib checks ?
    I think this is what is known as the "learning curve"
    now the work of understanding can buss protocols and the registers can begin
    Thanks for your patience and understanding

    Tim Painter

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #8
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,154
    Thumbs Up
    Received: 95
    Given: 1
    Total Downloaded
    2.59 GB

    0 Not allowed!

    Default Re: can buss macro compiler problem

    You only need to Skip Library Checks if you have a pbp file open in the desktop.
    When a compile is started, the Library Manager Pre-Compiler will check to see if any library files have been changed.
    Unless you are planning on modifying the library file in question you should leave this check enabled but ensure that you dont have the file open in the IDE.
    JohnB

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #9
    timpainter
    Guest timpainter's Avatar

    0 Not allowed!

    Default Re: can buss macro compiler problem

    Ok
    Thanks now i undersand

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #10
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,323
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    802.03 MB

    0 Not allowed!

    Default Re: can buss macro compiler problem

    Hi Tim,
    You might find this useful, it does not use any library commands, the purpose of it is to test your hardware to the CAN transceiver, if this does not run then there is no point in going any farther.
    As the comments say, do not change the xtal, if you have not got one then probably better to get one as I have tested this at that rate.

    Bob

    Code:
    '****************************************************************
    '*  Name    : CAN_LOOPBACK_4680.BAS                             *
    '*  Author  : Bobby Garrett                                     *
    '*  Notice  : Copyright (c) 2013 Bobby Garrett                  *
    '*          : All Rights Reserved                               *
    '*  Date    : 27/01/2013                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : Gone back to basics to try to find out what has   *
    '*          : broken using the new compiler 3.5.5.4 and my      *
    '*          : modifications for includes and queues etc.        *
    '****************************************************************
    
            Device = 18F4680  
    
    Config_Start
       OSC = HS ; HS oscillator
       FCMEN = On ; Fail-Safe Clock Monitor enabled
       IESO = OFF ; Oscillator Switchover mode disabled
       PWRT = On ; PWRT enabled
       BOREN = BOHW ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
       BORV = 0 ; Maximum Setting
       WDT = OFF ; HW Disabled - SW Controlled
       MCLRE = On ; MCLR pin enabled; RE3 input pin disabled
       LPT1OSC = OFF ; Timer1 configured for higher power operation
       PBADEN = OFF ; PORTB<4> and PORTB<1:0> Configured as Digital I/O Pins on Reset
       Debug = OFF ; Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
       XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
       LVP = OFF ; Single-Supply ICSP disabled
       STVREN = On ; Stack full/underflow will cause Reset
       CP0 = OFF ; Block 0 (000800-003FFFh) not code-protected
       CP1 = OFF ; Block 1 (004000-007FFFh) not code-protected
       CP2 = OFF ; Block 2 (008000-00BFFFh) not code-protected
       CP3 = OFF ; Block 3 (00C000-00FFFFh) not code-protected
       CPB = OFF ; Boot block (000000-0007FFh) not code-protected
       CPD = OFF ; Data EEPROM not code-protected
       WRT0 = OFF ; Block 0 (000800-003FFFh) not write-protected
       WRT1 = OFF ; Block 1 (004000-007FFFh) not write-protected
       WRT2 = OFF ; Block 2 (008000-00BFFFh) not write-protected
       WRT3 = OFF ; Block 3 (00C000-00FFFFh) not write-protected
       WRTB = OFF ; Boot block (000000-0007FFh) not write-protected
       WRTC = OFF ; Configuration registers (300000-3000FFh) not write-protected
       WRTD = OFF ; Data EEPROM not write-protected
    Config_End
    
            Xtal = 20                'Do not change unless you know what you are doing as the CAN 
                                     'settings are based on this.
            All_Digital = True       'Set all I/O to digital   
            
            Clear                    'Clear all memory locations
            
    'Set port direction On power up Or after reset        
            TRISA.0 = 0              'Set port direction - LED for diagnostics
    
    'Set state of port on power up or after reset
            PORTA.0 = 0              'Initialise output as off
    
    'Set Diplay up
            Declare LCD_Type 0 
            Declare LCD_Interface 4
            Declare LCD_Lines 2
            Declare LCD_DTPin = PORTD.4
            Declare LCD_ENPin = PORTD.2
            Declare LCD_RSPin = PORTD.3        
    
    'Set port direction for CAN I/O        
            TRISB.2 = 0              'Set port direction - CANTx pin as output
            TRISB.3 = 1              'Set port direction - CANRx pin as input 
    
    'Set up the CAN module               
            CANCON = %10000000       'Select config mode
            TXB0CON = 0              'Clear transmit buffer 0 control register
            RXB0CON = %00100000      'Receive only valid messages with standard identifier            
            TXB0DLC = %00001000      'RTR bit cleared, 8 byte data length
            RXB0DLC = %00001000      '8 byte data length
            
    'Set up the CAN module acceptance masks          
            RXM0SIDL = %00000000
            RXM0SIDH = %00000000
            
    'set up CAN hardware
            BRGCON1 = %00010011      'SJW = 1 Tq, Tq = 40/Fosc
            BRGCON2 = %11111111      'Phase seg 1 = 16 Tq, Sample 3 times
            BRGCON3 = %00000111      'Phase seg 2 = 8 Tq
            
            Set CIOCON.5             'ENDRHI  'recessive drives Tx to Vdd (required if using MCP 2551)
            
            CANCON = %01001000       'Select loopback mode For testing only !!!!
            PIR3 = 0                 'Clear interrupt register
            
            Dim LoopCtr As Byte      'Loop counter 
            Dim TotalCount As Dword  'Total number of TX 
            Dim Module1 As Byte
            Dim Module2 As Byte
            Dim Module3 As Byte
            Dim Module4 As Byte
            Dim Module5 As Byte
    
            Cls                      'Clear screen
            DelayMS 100                 ' Wait for PIC & LCD to start
            Print At 1,3,"Bobby Garrett's" 
            Print At 2,7,"RGV250"
            Print At 1,22,"  CAN BUS TEST"
            Print At 2,21,"    "
            DelayMS 1000             ' Show message for 2 seconds  
    
    send: 
            Cls                      'Clear screen  For testing
            For LoopCtr = 0 To 50          'For testing
            Inc TotalCount
            Toggle PORTA.0
                   
            TXB0D0 = LoopCtr         'For testing
            
    'Every count of 10 change the Tx identifier to simulate different unit
            If LoopCtr <= 10 Then TXB0SIDL = %00100000 : TXB0SIDH = %00000000
            If LoopCtr > 10 And LoopCtr <= 20 Then TXB0SIDL = %01000000 : TXB0SIDH = %00000000
            If LoopCtr > 20 And LoopCtr <= 30 Then TXB0SIDL = %01100000 : TXB0SIDH = %00000000
            If LoopCtr > 30 And LoopCtr <= 40 Then TXB0SIDL = %10000000 : TXB0SIDH = %00000000
            If LoopCtr > 40 And LoopCtr <= 50 Then TXB0SIDL = %10100000 : TXB0SIDH = %00000000
                                   
            TXB0CON = %00001001         'Start transmition, priority level 1 
    'Not sure but it appears there should be nothing between setting the bits and checking them?
    'I think this was a hardware issue but do not think that there should be anything between them anyway.
            While TXB0CON.3 = 1 : Wend                               
            
    'Every count of 10 change the Rx identifier to recieve message from "correct module"
            If LoopCtr <= 10 Then RXB0SIDL = %00100000 : RXB0SIDH = %00000000 : Module1 = RXB0D0
            If LoopCtr > 10 And LoopCtr <= 20 Then RXB0SIDL = %01000000 : RXB0SIDH = %00000000 : Module2 = RXB0D0
            If LoopCtr > 20 And LoopCtr <= 30 Then RXB0SIDL = %01100000 : RXB0SIDH = %00000000 : Module3 = RXB0D0
            If LoopCtr > 30 And LoopCtr <= 40 Then RXB0SIDL = %10000000 : RXB0SIDH = %00000000 : Module4 = RXB0D0
            If LoopCtr > 40 And LoopCtr <= 50 Then RXB0SIDL = %10100000 : RXB0SIDH = %00000000 : Module5 = RXB0D0
        
            DelayMS 500                 'For testing
           
            Print At 1,1, Dec LoopCtr   'For testing
            Print At 1,5, Dec TotalCount, "    "
            Print At 2,1, Dec Module1   'For testing
            Print At 2,5, Dec Module2   'For testing
            Print At 2,9, Dec Module3   'For testing
            Print At 2,13, Dec Module4  'For testing
            Print At 2,17, Dec Module5  'For testing
            
            Print At 2,21, Dec TXERRCNT, " TX ERR" 'For testing
            Print At 2,31, Dec RXERRCNT, " RX ERR" 'For testing
          
            Next LoopCtr                'For testing
            GoTo send                   'For testing

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #11
    timpainter
    Guest timpainter's Avatar

    0 Not allowed!

    Default Re: can buss macro compiler problem

    Hi
    Yes this works I am using a 18f4580 and the numbers clock up in sequence
    now i must find out what it all means!!
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #12
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,323
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    802.03 MB

    0 Not allowed!

    Default Re: can buss macro compiler problem

    Hi,
    All that is doing is proving that the the PIC to transciever is working, if you have a pre-built unit probably not a problem but as I made all mine it is good to prove that side before you go any farther.
    For your next step I would try to send messages one way, you should be able now to modify that file so that one has the TX code and the other has the RX code.
    I will have a look later to give you a few pointers, the main thing is to obviously change the mode from loopback to normal.

    Regards,
    Bob

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #13
    timpainter
    Guest timpainter's Avatar

    0 Not allowed!

    Default Re: can buss macro compiler problem

    Ok thanks
    I will get to it tommorw
    Tim

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #14
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,323
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    802.03 MB

    0 Not allowed!

    Default Re: can buss macro compiler problem

    Hi,
    I have done this quickly so might not work but should not be far off, let me know either way. one is for the TX and the other is for the RX, I have put some comments in so it should be understandable. You still do not need the library for this, that will come later.
    TX
    Code:
    '****************************************************************
    '*  Name    : CAN_NORMAL_4680_TX.BAS                            *
    '*  Author  : Bobby Garrett                                     *
    '*  Notice  : Copyright (c) 2013 Bobby Garrett                  *
    '*          : All Rights Reserved                               *
    '*  Date    : 27/01/2013                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : Just transmit one byte of information             *
    '*          :                                                   *
    '*          :                                                   *
    '****************************************************************
    
            Device = 18F4680  
    
    Config_Start
       OSC = HS ; HS oscillator
       FCMEN = On ; Fail-Safe Clock Monitor enabled
       IESO = OFF ; Oscillator Switchover mode disabled
       PWRT = On ; PWRT enabled
       BOREN = BOHW ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
       BORV = 0 ; Maximum Setting
       WDT = OFF ; HW Disabled - SW Controlled
       MCLRE = On ; MCLR pin enabled; RE3 input pin disabled
       LPT1OSC = OFF ; Timer1 configured for higher power operation
       PBADEN = OFF ; PORTB<4> and PORTB<1:0> Configured as Digital I/O Pins on Reset
       Debug = OFF ; Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
       XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
       LVP = OFF ; Single-Supply ICSP disabled
       STVREN = On ; Stack full/underflow will cause Reset
       CP0 = OFF ; Block 0 (000800-003FFFh) not code-protected
       CP1 = OFF ; Block 1 (004000-007FFFh) not code-protected
       CP2 = OFF ; Block 2 (008000-00BFFFh) not code-protected
       CP3 = OFF ; Block 3 (00C000-00FFFFh) not code-protected
       CPB = OFF ; Boot block (000000-0007FFh) not code-protected
       CPD = OFF ; Data EEPROM not code-protected
       WRT0 = OFF ; Block 0 (000800-003FFFh) not write-protected
       WRT1 = OFF ; Block 1 (004000-007FFFh) not write-protected
       WRT2 = OFF ; Block 2 (008000-00BFFFh) not write-protected
       WRT3 = OFF ; Block 3 (00C000-00FFFFh) not write-protected
       WRTB = OFF ; Boot block (000000-0007FFh) not write-protected
       WRTC = OFF ; Configuration registers (300000-3000FFh) not write-protected
       WRTD = OFF ; Data EEPROM not write-protected
    Config_End
    
            Xtal = 20                'Do not change unless you know what you are doing as the CAN 
                                     'settings are based on this.
            All_Digital = True       'Set all I/O to digital   
            
            Clear                    'Clear all memory locations
            
    'Set port direction On power up Or after reset        
            TRISA.0 = 0              'Set port direction - LED for diagnostics
    
    'Set state of port on power up or after reset
            PORTA.0 = 0              'Initialise output as off
    
    'Set Diplay up
            Declare LCD_Type 0 
            Declare LCD_Interface 4
            Declare LCD_Lines 2
            Declare LCD_DTPin = PORTD.4
            Declare LCD_ENPin = PORTD.2
            Declare LCD_RSPin = PORTD.3        
    
    'Set port direction for CAN I/O        
            TRISB.2 = 0              'Set port direction - CANTx pin as output
            TRISB.3 = 1              'Set port direction - CANRx pin as input 
    
    'Set up the CAN module               
            CANCON = 000000       'Select config mode
            TXB0CON = 0              'Clear transmit buffer 0 control register
            RXB0CON = 100000      'Receive only valid messages with standard identifier            
            TXB0DLC = 001000      'RTR bit cleared, 8 byte data length
            RXB0DLC = 001000      '8 byte data length
    
    'Set up the CAN module acceptance masks          
            TXB0SIDL = 000000
            TXB0SIDH = 000000
            
    'Set up the CAN module acceptance masks          
            RXM0SIDL = 000000     'Not needed for this test
            RXM0SIDH = 000000     'Not needed for this test
            
    'set up CAN hardware
            BRGCON1 = 010011      'SJW = 1 Tq, Tq = 40/Fosc
            BRGCON2 = 111111      'Phase seg 1 = 16 Tq, Sample 3 times
            BRGCON3 = 000111      'Phase seg 2 = 8 Tq
            
            Set CIOCON.5             'ENDRHI  'recessive drives Tx to Vdd (required if using MCP 2551)
            
            CANCON = 001000       'Select normal mode.
            PIR3 = 0                 'Clear interrupt register
            
            Dim LoopCtr As Byte      'Loop counter 
            Dim TotalCount As Dword  'Total number of TX 
            Dim Module1 As Byte
    
            Cls                      'Clear screen
            DelayMS 100                 'Wait for PIC & LCD to start
            Print At 1,3,"Bobby Garrett's" 
            Print At 2,7,"RGV250"
            Print At 1,22,"  CAN BUS TEST"
            Print At 2,21,"  TX   "
            DelayMS 1000             ' Show message for 1 seconds  
    
    send: 
            For LoopCtr = 0 To 255   'For testing
            Inc TotalCount
            Toggle PORTA.0
                   
            TXB0D0 = LoopCtr         'For testing
                                   
            TXB0CON = 001001      'Start transmition, priority level 1 
    'Not sure but it appears there should be nothing between setting the bits and checking them?
    'I think this was a hardware issue but do not think that there should be anything between them anyway.
            While TXB0CON.3 = 1 : Wend  
                                         
            DelayMS 500                 'For testing
           
            Print At 1,1, Dec LoopCtr, "   "   'Loop count.
            Print At 1,10, Dec TotalCount, "    "
            Print At 2,1, Dec Module1, "   "   'Data being sent, should match loop counter
            
            Print At 2,21, Dec TXERRCNT, " TX ERR" 'For testing
            Print At 2,31, Dec RXERRCNT, " RX ERR" 'For testing
          
            Next LoopCtr                'For testing
            GoTo send                   'For testing
    RX
    Code:
    '****************************************************************
    '*  Name    : CAN_NORMAL_4680_RX.BAS                            *
    '*  Author  : Bobby Garrett                                     *
    '*  Notice  : Copyright (c) 2013 Bobby Garrett                  *
    '*          : All Rights Reserved                               *
    '*  Date    : 27/01/2013                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : Just receive one byte of information              *
    '*          :                                                   *
    '*          :                                                   *
    '****************************************************************
    
            Device = 18F4680  
    
    Config_Start
       OSC = HS ; HS oscillator
       FCMEN = On ; Fail-Safe Clock Monitor enabled
       IESO = OFF ; Oscillator Switchover mode disabled
       PWRT = On ; PWRT enabled
       BOREN = BOHW ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
       BORV = 0 ; Maximum Setting
       WDT = OFF ; HW Disabled - SW Controlled
       MCLRE = On ; MCLR pin enabled; RE3 input pin disabled
       LPT1OSC = OFF ; Timer1 configured for higher power operation
       PBADEN = OFF ; PORTB<4> and PORTB<1:0> Configured as Digital I/O Pins on Reset
       Debug = OFF ; Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
       XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
       LVP = OFF ; Single-Supply ICSP disabled
       STVREN = On ; Stack full/underflow will cause Reset
       CP0 = OFF ; Block 0 (000800-003FFFh) not code-protected
       CP1 = OFF ; Block 1 (004000-007FFFh) not code-protected
       CP2 = OFF ; Block 2 (008000-00BFFFh) not code-protected
       CP3 = OFF ; Block 3 (00C000-00FFFFh) not code-protected
       CPB = OFF ; Boot block (000000-0007FFh) not code-protected
       CPD = OFF ; Data EEPROM not code-protected
       WRT0 = OFF ; Block 0 (000800-003FFFh) not write-protected
       WRT1 = OFF ; Block 1 (004000-007FFFh) not write-protected
       WRT2 = OFF ; Block 2 (008000-00BFFFh) not write-protected
       WRT3 = OFF ; Block 3 (00C000-00FFFFh) not write-protected
       WRTB = OFF ; Boot block (000000-0007FFh) not write-protected
       WRTC = OFF ; Configuration registers (300000-3000FFh) not write-protected
       WRTD = OFF ; Data EEPROM not write-protected
    Config_End
    
            Xtal = 20                'Do not change unless you know what you are doing as the CAN 
                                     'settings are based on this.
            All_Digital = True       'Set all I/O to digital   
            
            Clear                    'Clear all memory locations
            
    'Set port direction On power up Or after reset        
            TRISA.0 = 0              'Set port direction - LED for diagnostics
    
    'Set state of port on power up or after reset
            PORTA.0 = 0              'Initialise output as off
    
    'Set Diplay up
            Declare LCD_Type 0 
            Declare LCD_Interface 4
            Declare LCD_Lines 2
            Declare LCD_DTPin = PORTD.4
            Declare LCD_ENPin = PORTD.2
            Declare LCD_RSPin = PORTD.3        
    
    'Set port direction for CAN I/O        
            TRISB.2 = 0              'Set port direction - CANTx pin as output
            TRISB.3 = 1              'Set port direction - CANRx pin as input 
    
    'Set up the CAN module               
            CANCON = 000000       'Select config mode
            TXB0CON = 0              'Clear transmit buffer 0 control register
            RXB0CON = 100000      'Receive only valid messages with standard identifier            
            TXB0DLC = 001000      'RTR bit cleared, 8 byte data length
            RXB0DLC = 001000      '8 byte data length
    
    'Set up the CAN module acceptance masks          
            TXB0SIDL = 000000     'Not needed for this test
            TXB0SIDH = 000000     'Not needed for this test
            
    'Set up the CAN module acceptance masks          
            RXM0SIDL = 000000     
            RXM0SIDH = 000000     
            
    'set up CAN hardware
            BRGCON1 = 010011      'SJW = 1 Tq, Tq = 40/Fosc
            BRGCON2 = 111111      'Phase seg 1 = 16 Tq, Sample 3 times
            BRGCON3 = 000111      'Phase seg 2 = 8 Tq
            
            Set CIOCON.5             'ENDRHI  'recessive drives Tx to Vdd (required if using MCP 2551)
            
            CANCON = 001000       'Select normal mode.
            PIR3 = 0                 'Clear interrupt register
            
    
            Dim TotalCount As Dword  'Total number of RX 
            Dim Module1 As Byte
    
            Cls                      'Clear screen
            DelayMS 100                 'Wait for PIC & LCD to start
            Print At 1,3,"Bobby Garrett's" 
            Print At 2,7,"RGV250"
            Print At 1,22,"  CAN BUS TEST"
            Print At 2,21,"  RX  "
            DelayMS 1000             ' Show message for 1 seconds  
    
    Receive: 
            While RXB0CON.7 = 0 : Wend 'wait for a message
    
            Toggle PORTA.0        
            Inc TotalCount        
             
            Module1 = RXB0D0           'we have a message so copy the data                 
           
    
            Print At 1,10, Dec TotalCount, "    "  'total messages received
            Print At 2,1, Dec Module1, "   "       'Data being received
            
            Print At 2,21, Dec TXERRCNT, " TX ERR" 'For testing
            Print At 2,31, Dec RXERRCNT, " RX ERR" 'For testing
          
            RXB0CON.7 = 0              'We have done with the message now so reset the bit to allow another one
            
            GoTo Receive
    Bob
    Last edited by RGV250; 27th January 2013 at 21:42.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #15
    timpainter
    Guest timpainter's Avatar

    0 Not allowed!

    Default Re: can buss macro compiler problem

    Hi
    tryed your code no joy,
    I think the binary ident % was missing and i dont understand why the only 6 bits specified for registers
    i know my Tx and Rx harware works ok using some settings i lifted this from the forum (probably yours)
    sorry the code is a bit scruffy. and sorry still havent sused puting code in a window??
    '''=========== Can_bus_setup_18f4580.Inc ==================================================
    '' ;INITIALIZATION
    Dim node_ident As Byte
    node_ident=7
    TRISB = %00001000 ;CONFIGURE THE CAN DATA DIRECTION REGISTER
    'ecancon
    TRISB= %00101010
    ;CONFIGURING THE CAN BAUD RATE

    CANCON = %10000000 ;CAN MODULE SET TO CONFIGURATION MODE
    BRGCON1 = %00000011 ;CONFIGURE BAUD RATE = 250 KBITS/SEC
    BRGCON2 = %10100001
    BRGCON3 = %00000001

    ;SET UP CAN RECEIVE BUFFER 0
    CIOCON = %00100000 ;CAN TX PIN WILL DRIVE Vdd WHEN RECESSIVE
    ;SETTING REGISTERS FOR TRANSMISSION
    ' MDSEL0 = 0''ECANCON.6 ' Mode Select bits
    ' MDSEL1 =0'''ecANCON.7 ' Mode Select bits


    TXB0SIDH = %00000000
    TXB0SIDL = %00001000
    TXB0EIDH = %00000000
    'TXB0EIDL = %00000001 ; ident=1
    'TXB0EIDL = %00000111 ; ident=7
    TXB0EIDL =node_ident''TXB0EIDL =
    CANCON =%00000000 ;SET TO NORMAL MODE
    ' CANCON =%10000000 ; loopback
    ;SET UP INTERUUPTS
    'INTCON=%11000000 ;ENABLES GLOBAL INTERRUPTS
    'PIE3=%00000100 ;ENABLES TXB0 TRANSMIT INTERRUPT
    Dim data_0_Rx As Byte 'Rx/Tx user vars
    Dim data_1_RX As Byte
    Dim data_2_Rx As Byte
    Dim data_3_Rx As Byte
    Dim data_4_Rx As Byte
    Dim data_5_Rx As Byte
    Dim data_6_Rx As Byte 'rx
    Dim data_7_Rx As Byte

    Dim data_0_Tx As Byte 'Tx/Tx user vars
    Dim data_1_TX As Byte
    Dim data_2_Tx As Byte
    Dim data_3_Tx As Byte
    Dim data_4_Tx As Byte
    Dim data_5_Tx As Byte
    Dim data_6_Tx As Byte 'Tx
    Dim data_7_Tx As Byte


    '================================================= ================
    '=====================Rx========================== =====

    ;INITIALIZATION
    ''''''''''''''''TRISB = %00001000 ;CONFIGURE THE CAN DATA DIRECTION REGISTER
    TRISA =0
    ;CONFIGURING THE CAN BAUD RATE
    CANCON = %10000000 ;CAN MODULE SET TO CONFIGURATION MODE
    BRGCON1 = %00000011 ;CONFIGURE BAUD RATE = 250 KBITS/SEC
    BRGCON2 = %10100001
    BRGCON3 = %00000001
    ;SET UP CAN RECEIVE BUFFER 0
    CIOCON = %00100000 ;CAN TX PIN WILL DRIVE Vdd WHEN RECESSIVE
    RXB0CON= %00000000
    ;SET MASK
    RXM0SIDH = %00000000 ;IGNORE SIDH [accemp all]?
    RXM0SIDL = %00000000 ;IGNORE SIDL
    RXM0EIDH = %00000000 ;IGNORE EIDH
    RXM0EIDL = %11111111 ;COMPARE EACH BIT IN EIDL FOR ACCEPTANCE
    ;SET FILTER
    RXF0SIDH = %00000000 ;RXF0SIDH = 0
    RXF0SIDL = %00001000 ;EXIDE = 1 ==>EXTENDED ID, RXF0SIDL = 0
    RXF0EIDH = %00000000 ;RXF0EIDL = 0
    'RXF0EIDL = %00000001 ;RSF0EIDL = 1
    RXF0EIDL= node_ident ; ident
    CANCON = %00000000 ;CAN MODULE SET TO NORMAL MODE
    'CANCON = %01000000 ;CAN MODULE SET TO loop back MODE

    ;SET UP INTERUUPT SERVICE ROUTINE
    INTCON=%11000000 ;ENABLES GLOBAL INTERRUPTS
    PIE3=%00000101 ;ENABLES BUFFER0 AND TRANSMIT AND RECEIVE INTERRUPT

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. [SOLVED !] Problem with Writetimer0 macro or assembler?
      By J J Larsen in forum Proton Plus Compiler v3
      Replies: 2
      Last Post: 13th September 2010, 21:43
    2. [SOLVED !] CAN Buss Support
      By Bigbro_1985 in forum Pre-Sales and Upgrade Questions
      Replies: 3
      Last Post: 16th May 2010, 09:08
    3. Macro problem parameter
      By auban in forum Proton Plus Compiler v3
      Replies: 10
      Last Post: 6th October 2008, 21:40
    4. Problem in macro when para is 0
      By Roshan in forum Library Manager
      Replies: 4
      Last Post: 7th July 2008, 09:45
    5. Problem with MACRO's
      By RGV250 in forum Proton Plus Compiler v3
      Replies: 6
      Last Post: 8th April 2007, 16:58

    Members who have read this thread since 9th November 2019, 06:20 : 0

    Actions :  (Set Date)  (Clear Date)

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

    Tags for this Thread

    Posting Permissions

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