Can transmission problem on S5D9

Hello,

I want to send a can message with S5D9 board to a Pcan-usb Pro. The code is running (inspired buy CAN_HAL_DRIVER_MODULE on S7G2) but the message can't be received buy the PCAN (his green light blinking red when i send something).

I think it's because the can S5D9 Kbits/s isn't the same as PCAN Kbit/s. Indeed, " tx_flag= false"  so "CAN_EVENT_TX_COMPLETE" is false too. I have 500Kbits/s on PCAN and i tought i had 500Kbit/s too on S5G9. We I initialised S5G9 i used the documentation :

bit_rate = (fcanmclk/BRP)/(Tseg1+Tseg2+SS) = (60/5)/(15+8+1). What am i doing wrong ?    

Thanks you and sorry for my english.

  • Hi Thib,

    Which method you have used for transmission? Polling or interrupt?
  • Hi Thib,

    Which method you have used for transmission? Polling or interrupt?
  • Hello apu,

    I use transmission. I send a message by pushing the button SW5. If i can resolve this problem i will send message by interrupt.

    Thanks for your response.
  • In reply to Thib:

    Hi Thib
    Thank you for your response.

    Let me know if your interrupt is working for CAN transmission.
  • I just tried with a 500ms timer and i have the same problem.
  • Ok i found the solution ! The clock CAN MCLK is based on the clock XTAL (24 Mhz default value). So i had to put the BRP (Baud Rate Prescaler) from 5 to 2 and it's working.
  • In reply to Thib:

    r u talking about interrupt transmission or with polling?
  • In reply to apu:

    both
  • In reply to Thib:

    actually mine is working ok with polling but interrupt is not working
  • In reply to apu:

    Do you use a Timer 100ms for interrupt ?
  • In reply to apu:

    Hi thib,

    Can u explain y u changed BRP from 5 to 2.
    My crystal is 20mhz but peripheral clock for all peripheral module is 40mhz
  • In reply to Thib:

    no I dont use timer interrupt for CAN transmission
  • In reply to apu:

    which microcontroller u r using? I am using sh72531
  • In reply to apu:

    In sh72531,
    there is IRR8 (interrupt flag = which becomes 1 when TX is completed) -> once IRR8 becomes 1 and IMR8 (it unmask IRR8 interrupt) is unmasked, Interrupt should get generated, but Interrupt routine is not get called
  • In reply to apu:

    im using S5D97E3CFC. I changed BRP because my Fclock=24Mhz so :
    bit_rate = (fcanmclk/BRP)/(Tseg1+Tseg2+SS) = (24/2)/(15+8+1).