Blockset described on this wiki is deprecated since 2012.

For Model Based Design (MBD), use the free MPLAB Device Blocks for Simulink, tool from Microchip.
Updated Rapid Control Prototyping (RCP) custom projects are published at: https://lubin.kerhuel.eu.

Difference between revisions of "DsPIC Block/CAN Configuration"

From http://www.kerhuel.eu/wiki - Simulink device driver Blockset for dsPIC / PIC24 / PIC32 Microcontrollers --[[User:LubinKerhuel|LubinKerhuel]] 12:40, 3 September 2009 (UTC)
Jump to navigation Jump to search
m
(Based on PIC30F manual section 23, especially 23.6 and 23.10)
Line 2: Line 2:
 
Configuration for the CAN Peripheral
 
Configuration for the CAN Peripheral
  
When using either a CAN receive block or a CAN Transmit block, this block configure the mode and the CAN BUS parameters.
+
When using either a CAN Receive block or a CAN Transmit block, this block configure the mode and the CAN BUS parameters.
  
 
=Dialog Box Parameters=
 
=Dialog Box Parameters=
 
[[Image:Block_CanConfig_DialogBox.png|thumb|right|450px|CAN Configuration Dialog]]
 
[[Image:Block_CanConfig_DialogBox.png|thumb|right|450px|CAN Configuration Dialog]]
 
==Num CAN==
 
==Num CAN==
Ref to the CAN peripheral being configured (some PIC have two CAN bus)
+
Ref to the CAN peripheral being configured (some PICs have two CAN buses)
  
 
==Mode==
 
==Mode==
 
Configure the mode of the CAN peripheral. Four options are available.
 
Configure the mode of the CAN peripheral. Four options are available.
*Normal : the one you will use in most case.
+
*Normal : the one you will use in most cases.
*Loop back : Allow to test the CAN peripheral and the CAN blockset. In this mode, no external connection nor driver are necessary to make the CAN peripheral working. The dsPIC will write and read its own CAN messages.
+
*Loop back : Allows testing of the CAN peripheral and the CAN blockset. In this mode, no external connection or driver is necessary to make the CAN peripheral work. Messages transmitted are routed directly into the receive logic.
*Listen only : makes the microcontrolleur able to listen to the can BUS without writting anything. This mode will use only the Transmit PIN of the CAN peripheral The receve PIN can be used for another purpose.
+
*Listen only : The CAN peripheral receives messages on the bus without transmitting (not even acknowledge bits).
 +
This mode will use only the Receive pin of the CAN peripheral The Transmit pin can be used for another purpose.
 
*Disable : shut down the CAN peripheral.
 
*Disable : shut down the CAN peripheral.
  
 +
==These parameters configure the Timing of the CAN bus. Refer to the CAN documentation for more information.==
 +
The existing parameter prompts are poor: I have suggested new ones here
 +
(the block-set still looks as shown).
  
==Theses parameters configure the Timing of the CAN bus. Refere to the CAN doccumentation for more informations.==
 
 
*TRefCAN
 
*TRefCAN
*BaudRate
+
*Baud Rate Prescaler - 1
*Progagation Time Segment bits
+
*Propagation Time Segment quanta
 
*Phase Buffer Segment 1
 
*Phase Buffer Segment 1
*Sample of the CAN bus line
+
*Times to Sample  
 
*Phase Buffer Segment 2
 
*Phase Buffer Segment 2
 
*Synchronisation max jump (Tq)
 
*Synchronisation max jump (Tq)
The time quanta Tq and the BUS frequency Fcan are updated in the info parameter each time one of these parameters is modified.
+
 
 +
The time quanta Tq and the bus frequency Fcan are updated in the Info display each time one of these parameters is modified.
  
 
==Sample Time==
 
==Sample Time==
Line 34: Line 38:
  
 
==Info==
 
==Info==
Information, give the clock frequency Fscl of the I2C bus
+
Information: the time quantum length Tq  and the baud rate of the CAN, given the input oscillator timing TRefCan
 +
 
 +
==Warning==
 +
The baud rate is currently incorrectly given for at least the pic30f6014A.
 +
It corresponds to 1 more quantum than is actually given to each bit.
 +
Reduce one of the segment lengths by 1 quantum temporarily to see the
 +
correct baud rate.
 +
 
 +
In addition, the smallest bit length should be 8 quanta, but the block allows fewer
 +
than this to be configured (and shown in the Info display).
  
 +
I suspect this affects many, if not all, PIC microcontrollers with CAN (rather than ECAN) modules.
 
----
 
----
 
<comments \>
 
<comments \>

Revision as of 14:26, 20 April 2011

Block CAN Configuration

Configuration for the CAN Peripheral

When using either a CAN Receive block or a CAN Transmit block, this block configure the mode and the CAN BUS parameters.

Dialog Box Parameters

CAN Configuration Dialog

Num CAN

Ref to the CAN peripheral being configured (some PICs have two CAN buses)

Mode

Configure the mode of the CAN peripheral. Four options are available.

  • Normal : the one you will use in most cases.
  • Loop back : Allows testing of the CAN peripheral and the CAN blockset. In this mode, no external connection or driver is necessary to make the CAN peripheral work. Messages transmitted are routed directly into the receive logic.
  • Listen only : The CAN peripheral receives messages on the bus without transmitting (not even acknowledge bits).

This mode will use only the Receive pin of the CAN peripheral The Transmit pin can be used for another purpose.

  • Disable : shut down the CAN peripheral.

These parameters configure the Timing of the CAN bus. Refer to the CAN documentation for more information.

The existing parameter prompts are poor: I have suggested new ones here (the block-set still looks as shown).

  • TRefCAN
  • Baud Rate Prescaler - 1
  • Propagation Time Segment quanta
  • Phase Buffer Segment 1
  • Times to Sample
  • Phase Buffer Segment 2
  • Synchronisation max jump (Tq)

The time quanta Tq and the bus frequency Fcan are updated in the Info display each time one of these parameters is modified.

Sample Time

Sample time of the block. -1 for inherited

Block Ordering Input / Output

If you want to force the execution order of blocks that are not connected, this option allow to add either an input, an output or both to the block. These virtual connection allow to force the ordering of the blocks.

Info

Information: the time quantum length Tq and the baud rate of the CAN, given the input oscillator timing TRefCan

Warning

The baud rate is currently incorrectly given for at least the pic30f6014A. It corresponds to 1 more quantum than is actually given to each bit. Reduce one of the segment lengths by 1 quantum temporarily to see the correct baud rate.

In addition, the smallest bit length should be 8 quanta, but the block allows fewer than this to be configured (and shown in the Info display).

I suspect this affects many, if not all, PIC microcontrollers with CAN (rather than ECAN) modules.


<comments \>