CAN SPI baudrate

General discussion on mikroC PRO for AVR.
Post Reply
Author
Message
Nikitos
Posts: 40
Joined: 06 May 2015 15:07

CAN SPI baudrate

#1 Post by Nikitos » 02 Dec 2015 08:48

Hello everyone. Last time I found some things which are working on the CANBUS with baudrate 83.3 kBaud. Is it possible to program this baudrate by mikoe CAN SPI or CAN SPI click? I've tried to calculate nessesay quartz, but I did not found the best one. All calculation with possible error (minimal 0.04 %). Or maybe this baudrate needs something special?

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: CAN SPI baudrate

#2 Post by Aleksandar.Mitrovic » 02 Dec 2015 15:36

Hi,

Did you try to use our application for calculation of CAN, CANclulator:
http://www.libstock.com/projects/view/360/canculator

For setting baud rate with CAN SPI I suggest you to take a look at the CANSPI Library Help file.

Best regards,
Aleksandar

Nikitos
Posts: 40
Joined: 06 May 2015 15:07

Re: CAN SPI baudrate

#3 Post by Nikitos » 03 Dec 2015 06:37

Of cource I tried to use calculator. But as you can see on the picture there is no calculated data. It means that this baudrate impossible to CANSPI module? Or what can I do to set this baudrate without errors? I just want to connect CAN SPI to exist CAN BUS with baudrate 83.3 kBaud
Attachments
2015-12-03 07_54_40-MikroElektronika - CANculator.png
2015-12-03 07_54_40-MikroElektronika - CANculator.png (62.53 KiB) Viewed 5327 times

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: CAN SPI baudrate

#4 Post by Aleksandar.Mitrovic » 03 Dec 2015 15:41

Hi,

I mange to reproduce the same behavior.
The problem is in CANculator, for some reason he can not calculate correct settings for the PIC MCU.

For AVR, ARM and other is working.

This is forwarded to our developers.

You should set your CAN SPI manually.

Best regards,
Aleksandar

Nikitos
Posts: 40
Joined: 06 May 2015 15:07

Re: CAN SPI baudrate

#5 Post by Nikitos » 03 Dec 2015 21:06

I'm using PIC because as I remember there is a problem with AVR calculation. Can you help me to calculate this manually?

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: CAN SPI baudrate

#6 Post by Aleksandar.Mitrovic » 08 Dec 2015 17:03

Hi,

I suggest you to refer to the manual of the module which you are using.

Which module are you using?

Best regards,
Aleksandar

Nikitos
Posts: 40
Joined: 06 May 2015 15:07

Re: CAN SPI baudrate

#7 Post by Nikitos » 09 Dec 2015 05:49

1) EasyAVR v7 (Atmega32) -> CAN SPI click 5V (nessesary CAN BUS baudrate is 83.333 kBaud)
2) And one more question. How to make chip selection for two CAN SPI click 5v ?
For one module is:

Code: Select all

// CANSPI module connections
sbit CanSpi_CS  at  PORTB0_bit;
sbit CanSpi_CS_Direction  at  DDB0_bit;
How can I do this for two modules?
Is it good frequency of 8 Mhz to read and write both two can spi modules?

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: CAN SPI baudrate

#8 Post by Aleksandar.Mitrovic » 09 Dec 2015 15:35

Dear Nikitos,
Nikitos wrote:I'm using PIC because as I remember there is a problem with AVR calculation.
- To be honest I'm not sure that I understand with which microcontroller are you working now.

I manage to calculate the CAN settings for AVR in CANculator software (please take a look at the picture).

Therefore I suggest you to use that settings for CAN and test your hardware.

Best regards,
Aleksandar
Attachments
AVR_CANSPI.JPG
AVR_CANSPI.JPG (115.91 KiB) Viewed 5241 times

Nikitos
Posts: 40
Joined: 06 May 2015 15:07

Re: CAN SPI baudrate

#9 Post by Nikitos » 10 Dec 2015 06:16

Sorry. I explaned not completly. I used PIC only in calculation software because this post:

http://www.mikroe.com/forum/viewtopic.p ... 15#p217179

and answer to the post
janko.kaljevic wrote:Hello,

Yes this is an error when CANSPI and AVR controllers are selected.
In this case it generates double baud, as you noted.

Thanks for reporting this. It will be fixed for the next version of Canculator.

In meantime you can select other architecture (like PIC) and you will get correct calculation and generated code will compile.

Best regards.
Thanks for help!

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: CAN SPI baudrate

#10 Post by Aleksandar.Mitrovic » 10 Dec 2015 11:13

Hi Nikitos,

This was long time reported and fixed.

Now we have a different problem. :)

I hope that this will work for you.

Regards,
Aleksandar

Post Reply

Return to “mikroC PRO for AVR General”