1 2 Previous Next 24 Replies Latest reply on Apr 16, 2015 5:43 AM by EvPa_264126

    Can bus error

      Hi everybody,

         

      I work on a project which need the CAN Bus. I found many topics on internet about it with excellent examples (http://www.cypress.com/?docID=44342), but it doesn't work with me... :(

         

      When I do the same thing, no message is sent... The only difference is I use an internal clock, but I set on 24.000MHz.

         

       

         

      So, to check mistakes, I allowed Error Interrupts.

         

       

         

      With the debugger, I can see many interruption when I launch:

         
            
      • CAN_1_BitErrorIsr()
      •     
      • CAN_1_MsgErrorIsr()
      •     
      • CAN_1_BusOffIsr()
      •    
         

      Does anybody know where come from the mistakes ?

         

      Thank you for helping.

        • 1. Re: Can bus error
          JoMe_264151

          Welcome in the forum!

             

          An excerpt from the CAN component datasheet:

             

           

             

          In order for CAN component to operate properly, clock configuration should be set carefully. It is suggested that clock frequency is set as a multiple of desired baud rate. Also, accuracy of clock used (BUS_CLK for PSoC 3/PSoC 5LP or SYSCLK for PSoC 4200) must match the CAN clock tolerance requirement which is:
           1.58% or better for 125kbps and slower bit-rates
           0.5% or better for bit-rates faster than 125kbps

             

          and

             

          It is recommended to use an external XTAL or an external clock with higher accuracy as the clock source for the chip, if the internal clock tolerance is less than the desired value.

             

          So your problems might be caused by an unstable / unprecise clock with only 4% accuracy.

             

           

             

          Bob

          • 2. Re: Can bus error

            Firstly, thank you for your answer.

               

            Unfortunately, I can't use an external clock, I have to work with the internal.

               

            So, I set the IMO on 3.000MHz and 1% of accuracy "on Osc". Then, I changed the CAN speed for 125kps and BRP=2, Tseg1=5 and Tseg2 = 2.

               

            But I still have the same error...

            • 3. Re: Can bus error
              JoMe_264151

              When you post your complete project here, we all can have a look at. To do so, use
              Creator->File->Create Workspace Bundle (minimal)
              and attach the resulting file.



              Bob
               

              • 4. Re: Can bus error

                Here it is :)

                   

                For now, I send a message. When, I receive an answer, I change the pin_MLI status.

                • 5. Re: Can bus error
                  JoMe_264151

                  In your project the IMO was set to 3MHz which is correct, but you disabled the pll, so Master clock was only 3MHz.

                     

                  Checking further...

                     

                   

                     

                  Bob

                  • 6. Re: Can bus error

                    Sorry, I'm a beginner.

                       

                    I don't understand why I need the PLL ? 3.000 MHz for Master Clock is not good ? Must I have 24.000 MHz for the CAN bus ?

                    • 7. Re: Can bus error
                      JoMe_264151

                      I am using an early release of Creator 3.2 which comes with a CAN component version of 3.0. There you are forced to select (double click) one of the table entries given to set your CAN timings. Additionally the number of entries in the table is reduced to only 4 (four) and the combination you selected was flagged as invalid.

                         

                      Try one of the attaced combinations.

                         

                       

                         

                      Bob

                      • 8. Re: Can bus error
                        JoMe_264151

                        Attach failled second verse same as the first....

                           

                         

                           

                        Bob

                        • 9. Re: Can bus error
                          JoMe_264151

                          From CAN datasheet AC characteristics min clock is 8MHz. Using a 24MHz system clock is usual for power saving, I use a 48MHz system clock or even 66MHz for my projects.

                             

                           

                             

                          Bob

                          • 10. Re: Can bus error

                            Now, I activated the PLL:

                               

                             

                               

                            I set your values.

                               

                            But when I send a message, I received the error code: 161d (A1h).

                            • 11. Re: Can bus error
                              JoMe_264151

                              You get a bit-error (0x01). Additionally the flags for any error occured (0x80) and a transmission done (0x20).

                                 

                              The bit error comes from the receive side, I assume.

                                 

                               

                                 

                              Bob

                              • 12. Re: Can bus error

                                No, it is the emission side, when I do:

                                   

                                retour = CAN_1_SendMsg0();
                                    -> (in debug area) retour = 161

                                   

                                I don't emit and receive anything. I have an oscilloscope connected to Tx pin to see if any information goes out.

                                • 13. Re: Can bus error

                                  So, for test, I connected an external clock just to check.

                                     

                                  I changed the configuration of the clock:

                                     

                                   

                                     

                                  But when I try to send a message I have the same errors.

                                     

                                  CAN_1_SendMsg0() return me 161d and if I continue the code, I have the next errors functions:

                                     
                                        
                                  • CAN_1_BitErrorIsr()
                                  •     
                                  • CAN_1_MsgErrorIsr()
                                  •     
                                  • CAN_1_BusOffIsr()
                                  •    
                                     

                                  So it's not a problem of clocks

                                  • 14. Re: Can bus error
                                    JoMe_264151

                                    Yes, you do not transmit any data. You have to call _SendMsg() and provide a message to be stored in a mailbox to be transmitted.

                                       

                                     

                                       

                                    Bob

                                    1 2 Previous Next