avr_can icon indicating copy to clipboard operation
avr_can copied to clipboard

CAN_Sending Test not running with 8MHz internal oscillator

Open alessio31183 opened this issue 6 years ago • 8 comments

I've tried your library and the examples with the internal 8MHz oscillator. There is some problem running at that speed.

Any suggestion?

alessio31183 avatar Mar 27 '18 16:03 alessio31183

Which problems are you seeing?

thomasonw avatar Mar 27 '18 19:03 thomasonw

I've connected an Ixxat USB to can converter with the minion software to see the packet on the bus. Uploading the CAN_SendingTest on a board with the atmega64M1 I can receive the packets correctly only with the 16MHz external oscillator. There's no packets sent if I use the 8MHz internal oscillator. Even on the serial debugging I got "Failed" on any packet sent

alessio31183 avatar Mar 27 '18 20:03 alessio31183

OK, If you are having issues with the CAN and using the internal osc, that might not be surprising. The clock source for the CAN subsystems needs to be much more tight then the internal 8Mhz osc is able to provide. I have been using these: CSTCE16M0V13C99R0 0.1% with good success, but that is about as loose as one can get I think. And I believe there no way to get reliable CAN communications using the internal 8Mhz RC clock source, even if one selects the 1% 'factory calibrated' settings.

thomasonw avatar Mar 27 '18 21:03 thomasonw

Sorry but I've tried with an external 8MHz oscillator and I get the same result. No communication on the CANBUS with that example. I don't know exactly which component is but it's in the classic HC49 smd case. The CSTCE16M0V13C99R0 that you mentioned is a 16MHz oscillator. My application need to run at 8MHz because the power supply is 3.3V as the datasheet of ATmega64M1 suggests

speed_vs_vcc

alessio31183 avatar Mar 28 '18 07:03 alessio31183

If I try using the attiny1634 at 8MHz internal oscillator with the external can controller mcp2515 I can receive CAN messages. So in this case it works with the internal one. So it's not a oscillator frequency precision issue.

alessio31183 avatar Mar 28 '18 09:03 alessio31183

Hello.

Thanks for checking with an external osc. I looked over the lib and found that some of the timing values in avr_can.h did not match the suggested values in the spec sheet, specifically for 8Mhz rates of 250Kb/s and above. I have pushed up a corrected file just now.

On internal vs. external, you may well be able to get an example working, but careful review would be needed to assure the approach is stable over a larger number of examples, as well as temperature drifts. Running at lower CAN rates does help of course, and I know I have seen an example 'working' on an internal clock source (STM32F line), but am not comfortable it is viable outside a demo / one-off. If you do go down that path and have some insight into what would work and would not given the initial accuracy and temperature stability of the internal RC osc please make sure to share!

The resonator I pointed out is available on 8Mhz as well: CSTCE8M00G15L99-R0, or CSTCE8M00G15C99-R0 being examples. Of course if you have a low-vibration application traditional 8Mhz xtls are a great way to go as well.

Let me know if the corrections I just pushed up have good results for you.

tks,

thomasonw avatar Mar 28 '18 20:03 thomasonw

So.. I've tried to run the CAN_SendingTest with the external 8MHz and it works at all speed available in the avr_can.h Instead, using the internal one, nothing works at any speed

alessio31183 avatar Mar 29 '18 07:03 alessio31183

OK then. Thank you! Sounds like you verified the corrections fixed the 8Mhz issue, and confirmed the internal RC clock is not stable enough for CAN operation.

thomasonw avatar Mar 29 '18 14:03 thomasonw