izmit escort escort ankara adana escort

 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: CAN bus by MPC2515
PostPosted: Wed Aug 09, 2017 2:09 pm 
Offline

Joined: Wed Aug 02, 2017 11:16 am
Posts: 8
Hello,
I have 2 x CAN bus by spi1 using MPC2515.
Board:
- MCU AT91SAM9x25
- 4.4.26-linux4sam_5.5
- buildroot 2016.11.2

If I have enabled mmc1 in dtsi, so CAN bus works:
Code:
# ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

# ip link set can0 type can bitrate 125000 triple-sampling on
# ifconfig can0 up
# ifconfig
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)




If I have disabled mmc1 in dtsi, so after command "ifconfig can0 up" or "ifconfig can0 down", the console hangs! Then does not respond to command CTRL + C, it is possible only restart linux or create new SSH session (in new SSH session CAN bus not works):
Code:
# ip link set can0 type can bitrate 125000 triple-sampling on
# ifconfig can0 up

^C^C^C^C
^C


MMC1 definition in dtsi:
Code:
mmc1: mmc@f000c000 {
            pinctrl-0 = <   
               &pinctrl_board_mmc1
               &pinctrl_mmc1_slot0_clk_cmd_dat0
               &pinctrl_mmc1_slot0_dat1_3>;
            status = "okay";
            slot@0 {
               reg = <0>;
               bus-width = <4>;
               cd-gpios = <&pioD 14 GPIO_ACTIVE_HIGH>;
            };   
         };

pinctrl@fffff400 {
...
            mmc1 {
               pinctrl_board_mmc1: mmc1-board {
                  atmel,pins =
                     <AT91_PIOD 14 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_UP_DEGLITCH>;   // PD14 gpio CD pin pull up and deglitch
               };
            };
         };

mmc1 {
               pinctrl_mmc1_slot0_clk_cmd_dat0: mmc1_slot0_clk_cmd_dat0-0 {
                  atmel,pins =
                     <AT91_PIOA 13 AT91_PERIPH_B AT91_PINCTRL_NONE   /* PA13 periph B */
                      AT91_PIOA 12 AT91_PERIPH_B AT91_PINCTRL_PULL_UP   /* PA12 periph B with pullup */
                      AT91_PIOA 11 AT91_PERIPH_B AT91_PINCTRL_PULL_UP>;   /* PA11 periph B with pullup */
               };

               pinctrl_mmc1_slot0_dat1_3: mmc1_slot0_dat1_3-0 {
                  atmel,pins =
                     <AT91_PIOA 2 AT91_PERIPH_B AT91_PINCTRL_PULL_UP   /* PA2 periph B with pullup */
                      AT91_PIOA 3 AT91_PERIPH_B AT91_PINCTRL_PULL_UP   /* PA3 periph B with pullup */
                      AT91_PIOA 4 AT91_PERIPH_B AT91_PINCTRL_PULL_UP>;   /* PA4 periph B with pullup */
               };
            };


SPI1 definition in dtsi:
Code:
spi1: spi@f0004000 {
            #address-cells = <1>;
            #size-cells = <0>;
            compatible = "atmel,at91rm9200-spi";
            reg = <0xf0004000 0x100>;
            interrupts = <14 IRQ_TYPE_LEVEL_HIGH 3>;
            dmas = <&dma1 1 AT91_DMA_CFG_PER_ID(1)>,
                   <&dma1 1 AT91_DMA_CFG_PER_ID(2)>;
            dma-names = "tx", "rx";
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_spi1>;
            clocks = <&spi1_clk>;
            clock-names = "spi_clk";
            status = "disabled";
         };

spi1 {
               pinctrl_spi1: spi1-0 {
                  atmel,pins =
                     <AT91_PIOA 21 AT91_PERIPH_B AT91_PINCTRL_NONE   /* PA21 periph B SPI1_MISO pin */
                      AT91_PIOA 22 AT91_PERIPH_B AT91_PINCTRL_NONE   /* PA22 periph B SPI1_MOSI pin */
                      AT91_PIOA 23 AT91_PERIPH_B AT91_PINCTRL_NONE>;   /* PA23 periph B SPI1_SPCK pin */
               };
            };

spi1: spi@f0004000 {
            status = "okay";   
            cs-gpios = <&pioA 8 0>, <&pioA 0 0>, <&pioC 2 0>, <&pioC 3 0>;   
            
            mpc2515@0{
              compatible = "microchip,mcp2515";
              spi-max-frequency = <40000000>;               /* 40 MHz */
              reg = <2>;               /* CS2 */
              interrupt-parent = <&pioC>;         /* interrupt on port C */
              interrupts = <4 IRQ_TYPE_EDGE_FALLING>;   /* port C-4 */
              clocks = <&mcp_xtal>;
            };
            
            mpc2515@1{
              compatible = "microchip,mcp2515";
              spi-max-frequency = <40000000>;               /* 40 MHz */
              reg = <3>;               /* CS3 */
              interrupt-parent = <&pioC>;         /* interrupt on port C */
              interrupts = <5 IRQ_TYPE_EDGE_FALLING>;   /* port C-5 */
              clocks = <&mcp_xtal>;
            };
         };


SPI1 and MMC1 do not share pins:
SPI1 with MCP2515: PA21, PA22, PA23, PC2, PC3, PC4, PC5
MMC1: PA2, PA3, PA4, PA11, PA12, PA13, PD14

Probably the problem is pin PD14, because if I delete pin definition in mmc1 like this:
Code:
mmc1: mmc@f000c000 {
            pinctrl-0 = <   
               /*&pinctrl_board_mmc1
               &pinctrl_mmc1_slot0_clk_cmd_dat0
               &pinctrl_mmc1_slot0_dat1_3>;*/
            status = "okay";
            slot@0 {
               reg = <0>;
               bus-width = <4>;
               cd-gpios = <&pioD 14 GPIO_ACTIVE_HIGH>;
            };   
         };
In this case CAN buses works OK.

In my board I have button connect to pin PD14, because pin is defined for mmc1 I can not use PD14 like standard input gpio pin.

Thank you in advance

Regards
Emco


Top
 Profile  
Reply with quote  
 Post subject: Re: CAN bus by MPC2515
PostPosted: Thu Aug 10, 2017 12:03 am 
Offline

Joined: Thu Apr 19, 2007 10:15 pm
Posts: 1470
Location: USA
Emco wrote:
If I have enabled mmc1 in dtsi, so CAN bus works:
...
If I have disabled mmc1 in dtsi, so after command "ifconfig can0 up" or "ifconfig can0 down", the console hangs!

Emco wrote:
Probably the problem is pin PD14, because if I delete pin definition in mmc1 like this:
Code:
mmc1: mmc@f000c000 {
            pinctrl-0 = <   
               /*&pinctrl_board_mmc1
               &pinctrl_mmc1_slot0_clk_cmd_dat0
               &pinctrl_mmc1_slot0_dat1_3>;*/
            status = "okay";
            slot@0 {
               reg = <0>;
               bus-width = <4>;
               cd-gpios = <&pioD 14 GPIO_ACTIVE_HIGH>;
            };   
         };
In this case CAN buses works OK.
Maybe there's a language/translation issue here, because this seems to be contradictory.
And your hypothesis that pin PD14 is suspect makes no sense at all, since you disable all the data and control lines rather than that one pin.

It's very likely this is a board layout issue, rather than a DT configuration issue.
Perhaps you need to verify HW functionality using standalone code (e.g. derived from the Atmel Software Package and/or U-Boot).

Regards


Top
 Profile  
Reply with quote  
 Post subject: Re: CAN bus by MPC2515
PostPosted: Mon Aug 21, 2017 3:11 pm 
Offline

Joined: Wed Aug 02, 2017 11:16 am
Posts: 8
My problem was in hardware. For MPC2515 I had crystal 8MHz with capacitors 2 x 27pF. But my crystal have Load capacitance (CL) only 18pF (by datsheet), so I change capacitors from 2 x 27pF to 2 x 15pF and now is all right. Both CAN bus works correctly.

Thank you

Regards
Emco


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron