# CANPS with PYNQ

**URL:** <https://discuss.pynq.io/t/canps-with-pynq/6979>\
**Category:** Support\
**Created:** [May 3, 2024, 1:04pm UTC](https://discuss.pynq.io/t/canps-with-pynq/6979 "2024-05-03T13:04:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![saeed123](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/saeed123/32/5837_2.png) [@saeed123](https://discuss.pynq.io/u/saeed123)\
**Post date:** [May 3, 2024, 1:04pm UTC](https://discuss.pynq.io/t/canps-with-pynq/6979/1 "2024-05-03T13:04:29Z")

</div>

Hello Dears,  
I use PYNQ-Z2 board, the pynq version which I am using is v3.1.  
Vivado design is attached .  
CAN0,1 use from EMIO pins.  
The code which I have used is:

from pynq import MMIO  
from pynq import Overlay  
from pynq import ps  
from pynq import GPIO  
from pynq import registers  
from pynq import allocate  
import numpy as np  
import sys  
sys.path.insert(1, ‘./src’)  
ol=Overlay(“./bits/FullInterfaceWrapper.bit”)  
ol.download()  
ps.Clocks.fclk0\_mhz=100.0  
BASE\_ADDRESS = 0xE0009000#CAN

mmio=MMIO(BASE\_ADDRESS,8)  
result=mmio.read(0)

Code hangs when reach to ‘result=mmio.read(0)’

 ![image](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/9/9cd1440d2ca0ff1332acb15114ec8ca42dfde922.png)  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/7/7c5044b1225e1b3154a092a513625ece22e67dda.png)

Why the arm processor is hanged?

---

<div class="post-metadata">

**Author:** ![marioruiz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/marioruiz/32/2177_2.png) [@marioruiz](https://discuss.pynq.io/u/marioruiz)\
**Post date:** [May 3, 2024, 3:04pm UTC](https://discuss.pynq.io/t/canps-with-pynq/6979/2 "2024-05-03T15:04:04Z")

</div>

Hi @saeed123,

`pynq.mmio()` reads and writes from IP in the PL via the GP ports. The CAN IP and base address are associated to the PS, hence when you try to read the board crashes.

Mario

---

<div class="post-metadata">

**Author:** ![saeed123](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/saeed123/32/5837_2.png) [@saeed123](https://discuss.pynq.io/u/saeed123)\
**Post date:** [May 5, 2024, 12:04pm UTC](https://discuss.pynq.io/t/canps-with-pynq/6979/3 "2024-05-05T12:04:28Z")

</div>

Dear @marioruiz , what is the solution to work with CAN in PS section without consuming PL gates? How I can access to these registers for reading and writing into them? Is there any proper library to handle CAN in python environment for Pynq-z2?

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/system/32/2_2.png) [@system](https://discuss.pynq.io/u/system)\
**Post date:** [May 8, 2024, 12:05pm UTC](https://discuss.pynq.io/t/canps-with-pynq/6979/4 "2024-05-08T12:05:24Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![cathalmccabe](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/cathalmccabe/32/3348_2.png) [@cathalmccabe](https://discuss.pynq.io/u/cathalmccabe)\
**Post date:** [May 8, 2024, 1:05pm UTC](https://discuss.pynq.io/t/canps-with-pynq/6979/5 "2024-05-08T13:05:04Z")

</div>

The CAN IP in the PS doesn’t have a Python API in PYNQ.  
You would need to write this yourself, or use an existing driver.

Cathal
