Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic18f458 interfacing with mcp2551-problem

Status
Not open for further replies.

alekarasma

Newbie level 2
Newbie level 2
Joined
Dec 27, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
18
Hello Everyone i m interfacing pic18f458 with mcp2551....but it is not giving me the required output
this is my code for transmitter side


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
void main()
{
InitECAN();
}
 
 
void InitECAN(void)
{
    // Enter CAN module into config mode
    CANCON = 0x80;    //REQOP<2:0>=100
    while(!(CANSTATbits.OPMODE2==1));
        BRGCON1 = 0x01; 
        BRGCON2 = 0x90;  
        BRGCON3 = 0x02; 
    
    
    // Enter CAN module into normal mode
    CANCON = 0x00;
    while(!(CANSTATbits.OPMODE2==0));
        
        TXB1CON =0x03;
        TXB1SIDH=0x7E;
        TXB1SIDL=0x00;
        TXB1DLC =0x01;
        TXB1D0  ='A';
        TXB1CONbits.TXREQ = 1; //Set the buffer to transmit
}
 
 
and this is the code for receiver side
 
 
void main()
{
InitECAN();
}
 
 
void InitECAN(void)
{
 // Enter CAN module into config mode
    CANCON = 0x80;    //REQOP<2:0>=100
    while(!(CANSTATbits.OPMODE2==1));
        BRGCON1 = 0x01; 
        BRGCON2 = 0x90;  
        BRGCON3 = 0x02; 
        RXM0SIDH=0xFF;
        RXM0SIDL=0xFF;  // Set to all ‘1’s so filter must match every bit
        RXF0SIDH=0xFF;
        RXF0SIDL=0xFF;
        RXF1SIDH=0xFF;
        RXF1SIDL=0xFF;
 
        RXM1SIDH=0x7E;  //
        RXM1SIDL=0x00;
        RXF2SIDH=0x7E;  //Filter 2 matches 0x3f0
        RXF2SIDL=0x00;
    
    // Enter CAN module into normal mode
    CANCON = 0x00;
    while(!(CANSTATbits.OPMODE2==0));
   
        
        while(!RXB1CONbits.RXFUL); //CheckRXB1
                data=RXB1D0;
               SendByteSerially(data);
 
}

please help me....
thank you
 
Last edited by a moderator:

Hello Everyone i m interfacing pic18f458 with mcp2551....but it is not giving me the required output
this is my code for transmitter side


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
void main()
{
InitECAN();
}
 
 
void InitECAN(void)
{
    // Enter CAN module into config mode
    CANCON = 0x80;    //REQOP<2:0>=100
    while(!(CANSTATbits.OPMODE2==1));
        BRGCON1 = 0x01; 
        BRGCON2 = 0x90;  
        BRGCON3 = 0x02; 
    
    
    // Enter CAN module into normal mode
    CANCON = 0x00;
    while(!(CANSTATbits.OPMODE2==0));
        
        TXB1CON =0x03;
        TXB1SIDH=0x7E;
        TXB1SIDL=0x00;
        TXB1DLC =0x01;
        TXB1D0  ='A';
        TXB1CONbits.TXREQ = 1; //Set the buffer to transmit
}
 
 
and this is the code for receiver side
 
 
void main()
{
InitECAN();
}
 
 
void InitECAN(void)
{
 // Enter CAN module into config mode
    CANCON = 0x80;    //REQOP<2:0>=100
    while(!(CANSTATbits.OPMODE2==1));
        BRGCON1 = 0x01; 
        BRGCON2 = 0x90;  
        BRGCON3 = 0x02; 
        RXM0SIDH=0xFF;
        RXM0SIDL=0xFF;  // Set to all ‘1’s so filter must match every bit
        RXF0SIDH=0xFF;
        RXF0SIDL=0xFF;
        RXF1SIDH=0xFF;
        RXF1SIDL=0xFF;
 
        RXM1SIDH=0x7E;  //
        RXM1SIDL=0x00;
        RXF2SIDH=0x7E;  //Filter 2 matches 0x3f0
        RXF2SIDL=0x00;
    
    // Enter CAN module into normal mode
    CANCON = 0x00;
    while(!(CANSTATbits.OPMODE2==0));
   
        
        while(!RXB1CONbits.RXFUL); //CheckRXB1
                data=RXB1D0;
               SendByteSerially(data);
 
}

please help me....
thank you



I FORGOT TO TELL...

i m using pic18f458 with 4mhz crystal and 125kbps speed for CAN
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top