Pin_Read() function not working

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello,

I've been stuck with this problem with simple data read-in for a while now, I would appreciate any suggestion:

I write a 3-bit request to an external module, which answers me with 3 bits of data. I checked everything with a scope, the module works properly and answers in 5V binary levels, But, i can't read this data with my CY8C5888AXI-LP096 input pins. I also tried writing mtdat value directrly to other pins, but no luck there either, I must be missing something obvious. Thank you

int n;

int MTMUX0[6]={1, 0, 1, 0, 1, 0}; /* 0bit of six different request codes*/

int MTMUX1[6]={0, 1, 1, 0, 0, 1}; /* 1bit of six different request codes*/

int MTMUX2[6]={0, 0, 0, 1, 1, 1}; /* 2bit of six different request codes*/

int MTDAT0; /*array of 0bits of  module answers*/

int MTDAT1;

int MTDAT2;

    for (;;) {

        for (n=0; n<6; n++) {

    MuxOut0_Write(MTMUX0); /*write from MTMUX arrays to module*/  

    MuxOut1_Write(MTMUX1);

    MuxOut2_Write(MTMUX2);

          CyDelayUs(tdelay); /*delay*/

    MTDAT0=MtDat0_Read(); /*read from module into MTDAT arrays*/

    MTDAT1=MtDat1_Read();

    MTDAT2=MtDat2_Read();

}}

pastedImage_36.png

0 Likes
8 Replies
Anonymous
Not applicable

Here is fixed code, sorry:

int n;

int MTMUX0[6]={1, 0, 1, 0, 1, 0}; /* 0bit of six different request codes*/

int MTMUX1[6]={0, 1, 1, 0, 0, 1}; /* 1bit*/

int MTMUX2[6]={0, 0, 0, 1, 1, 1}; /* 2bit*/

int MTDAT0; /*array of 0bits of  module answers*/

int MTDAT1;

int MTDAT2;   

for (;;) {        

     for (n=0; n<6; n++) {    

MuxOut0_Write(MTMUX0); /*write from MTMUX arrays to module*/      

MuxOut1_Write(MTMUX1);    

MuxOut2_Write(MTMUX2);          

CyDelayUs(tdelay); /*delay*/    

MTDAT0=MtDat0_Read(); /*read from module into MTDAT arrays*/    

MTDAT1=MtDat1_Read();    

MTDAT2=MtDat2_Read(); }}

0 Likes
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

You can use "Syntax Highlighting" feature on the advanced editor.

    int MTDAT0; /*array of 0bits of  module answers*/

    int MTDAT1;

    int MTDAT2;  

What is the size of the MTDATAx[] array?  I thought that the size number in the bracket should not be a variable.  Did you see any ERROR when compiling?

Regards,

Noriaki

0 Likes
Anonymous
Not applicable

This is a mistake of re-writing, in my original code it's size is  [6], sorry.

Also, I forgot to mention i already tried Digital Hi-Z configuration.

0 Likes
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

Please confirm followings.

  1. Are these MtDatX pins assigned to the pin connected to the module output in the CYDWR?
  2. Is the tdelay value larger than the setup time of the module?
  3. Is the module has enough hold time?  Or add some delay after reading the pin states.

Regards,

Noriaki

0 Likes
Anonymous
Not applicable

1. Assignations are correct, 2.  t delay is time given for the module to change it's output - the longer the better. 3 This was my best guess too, and I already tried adding delay after read command, but sadly it didn't work either

0 Likes

Can you please post your complete project so that we all can have a look at all of your settings. To do so, use

Creator->File->Create Workspace Bundle (minimal)

and attach the resulting file.

Some of your scope pictures with correct timing could be very helpful too.

Bob

0 Likes
Anonymous
Not applicable

Yes, here is the project.

http://www.filedropper.com/workspace01cywrkarchive01

Also, some details:

Pin_Read() function is not totally dead, it reads the pins somewhat ok, but not in all cycle iterations.

For example, the module gives out:

2- 1 1 1 1 0 0

1- 1 1 0 0 0 0

0- 0 1 0 1 0 0;

And Cypress reads it:

2- 1 0 0 0 0 0

1- 1 0 0 0 0 0

0- 0 1 0 1 0 0

23158365_10204045206167128_2108154816_o.jpg

0 Likes
Anonymous
Not applicable

codee.png

0 Likes