• Content Count

  • Joined

  • Last visited

About daeroro

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi, I'm using zybo-z7 10 and pmod CAN. Now I'm trying to build pmod CAN petalinux user app. But first of all, I want to handle spi transfer, so I build spi example code. I'm using petalinux 2017.4 and vivado 2018.2. And hardware design referenced from here : https://reference.digilentinc.com/learn/programmable-logic/tutorials/pmod-ips/start and device tree (in ~/CAN_fpga/project-spec/meta-user/recipes-bsp/device-tree/files/system_user.dtsi) : /include/ "system-conf.dtsi" / { }; &spi0 { is-decoded-cs = <0>; num-cs = <1>; status = "okay"; spidev@0x00 { compatible = "spidev"; spi-max-frequency = <10000000>; reg = <0>; }; }; and the user app code: ------------------------------------------------------------------------------- #include <stdio.h> #include <string.h> #include <stdint.h> #include <stdlib.h> #include <unistd.h> #include <sys/mman.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <linux/types.h> #include <linux/spi/spidev.h> #define SPI_DEV "/dev/spidev32766.0" int main(void) { int fd, i; int rbuf[128]; const char * name = SPI_DEV; int readcount = 8; int msglen = 8; if((fd = open(SPI_DEV, O_RDWR))<0) { perror("Open error: "); exit(-1); } printf("Open success\n"); dumpstat(name, fd); printf("before do_msg\n"); if (msglen) do_msg(fd, msglen); printf("after do_msg\n"); if (readcount) do_read(fd, readcount); return 0; } static void do_read(int fd, int len) { unsigned char buf[32], *bp; int status; /* read at least 2 bytes, no more than 32 */ if (len < 2) len = 2; else if (len > sizeof(buf)) len = sizeof(buf); memset(buf, 0, sizeof buf); status = read(fd, buf, len); if (status < 0) { perror("read"); return; } if (status != len) { fprintf(stderr, "short read\n"); return; } printf("read(%2d, %2d): %02x %02x,", len, status, buf[0], buf[1]); status -= 2; bp = buf + 2; while (status-- > 0) printf(" %02x", *bp++); printf("\n"); } static void do_msg(int fd, int len) { struct spi_ioc_transfer xfer[2]; unsigned char buf[32], *bp; int status; memset(xfer, 0, sizeof xfer); memset(buf, 0, sizeof buf); if (len > sizeof buf) len = sizeof buf; buf[0] = 0xaa; xfer[0].tx_buf = (unsigned long)buf; xfer[0].len = 1; xfer[1].rx_buf = (unsigned long) buf; xfer[1].len = len; printf("before do_msg ioctl\n"); status = ioctl(fd, SPI_IOC_MESSAGE(2), xfer); printf("after do_msg ioctl\n"); if (status < 0) { printf("status : %d\n", status); perror("SPI_IOC_MESSAGE"); return; } printf("response(%2d, %2d): ", len, status); for (bp = buf; len; len--) printf(" %02x", *bp++); printf("\n"); } static void dumpstat(const char *name, int fd) { __u8 lsb, bits; __u32 mode, speed; if (ioctl(fd, SPI_IOC_RD_MODE32, &mode) < 0) { perror("SPI rd_mode"); return; } if (ioctl(fd, SPI_IOC_RD_LSB_FIRST, &lsb) < 0) { perror("SPI rd_lsb_fist"); return; } if (ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits) < 0) { perror("SPI bits_per_word"); return; } if (ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) < 0) { perror("SPI max_speed_hz"); return; } printf("%s: spi read mode 0x%x, %d bits %sper word, %d Hz max\n", name, mode, bits, lsb ? "(lsb first) " : "", speed); } ------------------------------------------------------------------------------------------------------------------------------ I want to control spi in duplex mode using ioctl() bolded above code. But the result is : - SPI transfer timed out -> ioctl() function doesn't work properly, I think. Could you give me some advice?
  2. daeroro

    pmod can period

    Well, I figure out a bug in the example code. In the CAN_Configure function : // Set CAN control mode to configuration CAN_ModifyReg(InstancePtr, CAN_CANCTRL_REG_ADDR, CAN_CAN_CANCTRL_MODE_MASK, CAN_ModeConfiguration ); needs to be changed like this: CAN_ModifyReg(InstancePtr, CAN_CANCTRL_REG_ADDR, CAN_CAN_CANCTRL_MODE_MASK, CAN_ModeConfiguration << CAN_CANCTRL_MODE_BIT); So it can enter the configuration mode... After changing the code, CAN communication between Zybo-z7 and MCU works really well. You need to change your git example code.
  3. daeroro

    pmod can period

    Hi, @jpeyron Thanks for reply. Unfortunately, I can't alter the bit rate. The graph was changed even if I used same hardware design and SDK example. I don't know why. Have you ever tried to change bit rate and it worked?? thanks!!
  4. daeroro

    pmod can period

    Hi, vicentiu. I'm using vivado + sdk -hardware design : https://reference.digilentinc.com/learn/programmable-logic/tutorials/pmod-ips/start -sdk example : https://github.com/Digilent/vivado-library/blob/master/ip/Pmods/PmodCAN_v1_0/drivers/PmodCAN_v1_0/examples/TX.c + I ran the Lookback.c example and it worked!!
  5. daeroro

    pmod can period

    Hello, I'm working on zybo z7 & pmod can I want to transmit data from zybo z7 to other board(not zybo, tms570lc43x launchpad). So I took a test : (computer) - (usb2can) --------------------------- (can transceiver) - (tms570 board). It really worked well. But I took a test like this: (zybo-z7) - (pmod can) -------------------------------------- (can transceiver) - (tms570 board) It doesn't work!!!!! and the signal period is about 8 times slower than above picture.. How can I make it work? I need your advice thanks!!
  6. Thanks for answering @jpeyron Well,,, you missed the hyperlink of data sheet.. I already run the loop back demo and it did work properly. What I really want to do is transmitting data from fpga(zybo-z7) to mcu(TMS570LC4357 launch pad). So bit timing configuration is important, I think. Is that right that if I change the bit rate, the oscilloscope waveform changes? (What I meant is deltaT in waveform below) The deltaT(in below graph) doesn't change at all best regards, daero
  7. Thanks for reply!! I made vivado block design referencing this tutorial -> https://reference.digilentinc.com/learn/programmable-logic/tutorials/pmod-ips/start And the sdk code reference is this -> https://github.com/Digilent/vivado-library/blob/master/ip/Pmods/PmodCAN_v1_0/drivers/PmodCAN_v1_0/examples/TX.c The mode TX.c example uses is normal! Is this right that Pmod CAN has internal 20MHz clock source? In the schematic below, CSTCE20MV13L99-R0 datasheet says it's 20MHz Sorry for BAD english again..! Thanks for reading!!
  8. Hi I'm using pmod CAN module to communicate between zybo z7-10 and tms570LC4357 launch pad(Texas Instrument). The connection is like this : zybo z7-10( - Pmod CAN module) ----------------- CAN trasceiver(SN65HVD230) -- tms570LC4357 launch pad I took a test with zybo z7-10 - tms570LC4357 launch pad(bit rate = 250kbps), the oscilloscope graph is the graph with delta x = 82us, 1/delta x = 12.2KHz. And CAN doesn't work.. (the probe is picking CANH(red), CANL(yellow) in Pmod CAN module) I'd like to change bit rate, so I took a look the datasheet ( mcp25625). And change registers CNF1, CNF2, CNF3 CNF1 (0x41) -> (0x09) CNF2 (0xFB) -> (0xFF) CNF3 (0x86) -> (0x87) 250kbps -> 40kbps but...! the graph's period doesn't change at all.. Is there anything I shall do more things to change bit rate? Sorry for bad english.. please answer.. thx!!