解決済! 解決策の投稿を見る。
You will first of all need a reliable clock source, ie an external crystal or external oscillator. Then setup either the RTC or one of the other hardware timers ("ECT" on S12). You may have to pick an oscillator frequency that is both suitable for the timer prescalers and the CAN baudrate prescaler. Any multiple of 10MHz should do the trick (personally Im using a 20MHz pierce oscillator for very similar applications).
Once you are sure of the clock, you will need to setup the timer to a given interval (either interrupts or polling should work). You may or may not be able to have the timer flag after 10ms. If you can't pick that long a time, the software will need to count the number of timer completions until you've had the correct amount equal to 10ms.
When you have reached the 10ms, execute the transmission code. For the simplest way of doing this, have your main() loop wait & poll until it receives the timer flag.
Naturally you can't send all 14 messages at once, as the CAN bus is serial. You will need to calculate how long it takes to send them. For example: With minimum overhead (11-bit identifier) and 8 bytes of data in each CAN frame, you'll get 47+8*8=111 bits of data per package, counting intermissions between messages. Ie 14*111 = 1554 bits. With baudrate 125kbps, it would take 12.43ms to send them all, assuming you have free reign over the bus. In other words, in this case you wouldn't be able to send them all before 10ms have ellapsed.
You will first of all need a reliable clock source, ie an external crystal or external oscillator. Then setup either the RTC or one of the other hardware timers ("ECT" on S12). You may have to pick an oscillator frequency that is both suitable for the timer prescalers and the CAN baudrate prescaler. Any multiple of 10MHz should do the trick (personally Im using a 20MHz pierce oscillator for very similar applications).
Once you are sure of the clock, you will need to setup the timer to a given interval (either interrupts or polling should work). You may or may not be able to have the timer flag after 10ms. If you can't pick that long a time, the software will need to count the number of timer completions until you've had the correct amount equal to 10ms.
When you have reached the 10ms, execute the transmission code. For the simplest way of doing this, have your main() loop wait & poll until it receives the timer flag.
Naturally you can't send all 14 messages at once, as the CAN bus is serial. You will need to calculate how long it takes to send them. For example: With minimum overhead (11-bit identifier) and 8 bytes of data in each CAN frame, you'll get 47+8*8=111 bits of data per package, counting intermissions between messages. Ie 14*111 = 1554 bits. With baudrate 125kbps, it would take 12.43ms to send them all, assuming you have free reign over the bus. In other words, in this case you wouldn't be able to send them all before 10ms have ellapsed.
The calculation is on bus load only: the time it takes to send the messages over the copper wires on the CAN bus.
So an X-gate won't solve anything. This is very fundamental physics... distance = speed * time, where the distance in this case is the number of bits that needs to be spitted out.
With adequate software, interrupts should not delay transfer times a lot. Even at 1Mbps single CAN message takes about 0.1ms. That's plenty of CPU time even at minimum required oscilator/PLL clock (16MHz is enough, not sure about less than that).
While your messages are being transferred you can't receive other messages, unless your node loses arbitration because other node is sending higher priority messages, which will delay you much more than CPU interrupt processing time.
Also, MSCAN has 5 RX buffers. Depending on how many messages you expect to receive during a certain time period, this may be enough. And unless they need to be served right away, there is perhaps no need for interrupts either.