DigitalComp_v1_0 does not work for the case of using >= and second operand zero.

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

cross mob
JoWi_3984961
Level 4
Level 4
First like received First like given

It gives the wrong result.  Using PSoC 4, one of the EVM units.  Anyone else see it?

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

(1) In my previous post my 8bit sample was testing only up to 0x0F for each A, B,

so I fixed them to up to 0xFF but there was no error reported. (comp_test_8bit)

(2) Then I connected 8 x Logic '0 's to B port of DigitalComp, but it caused PSoC Creator to be unable to compile.

Somehow Control_Reg for A ended up to be undefined. (this could be a bug, though...)

(3) Then I re-hired a Control_Reg for B and in the beginning of the  program I assigned 0 to Control_Reg for B

and looped A from 0x00 to 0xFF, this is the "case X >= 0" is tested.

And again no error was reported. (comp_test_8bit_op0)

So in general DigitalComp seems to be working.

But just like (2), there may be a combination which causes problem to PSoC Creator.

So your sample project which can re-produce the problem would be appreciated.

moto

View solution in original post

7 Replies
LinglingG_46
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 10 questions asked

Could you attached a simple project to reproduce the issue?

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I tried some brute force approach.

I created following schematic for CY8CKIT-044

004-Schematic.JPG

and let PSoC to test all combinations of 4bit A and 4 bit B.

=========================

#include "project.h"

#include <stdio.h>

char str[128] ; /* print buffer */

void print(char *str)

{

    UART_UartPutString(str) ;

}

void init_hardware(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

    UART_Start() ;

}

int main(void)

{

    int a, b, digicmp, expect ;

    int error_count = 0 ;

  

    init_hardware() ;

  

    sprintf(str, "DigitalComp Test 4bit (%s %s)\n", __DATE__, __TIME__) ;

    print(str) ;

  

    for (b = 0 ; b < 0x10 ; b++ ) {

        B_Write(b) ;

        for (a = 0 ; a < 0x10 ; a++ ) {

            A_Write(a) ;

            CyDelay(1) ; /* wait 1ms */

            digicmp = DCOUT_Read() ;

            expect = (a >= b) ? 1 : 0 ;

            sprintf(str, "%02X %02X %d %d ", a, b, digicmp, expect) ;

            print(str) ;

            if (digicmp == expect) {

                print("OK\n") ;

            } else {

                print("Error!\n") ;

                error_count++ ;

            }

            CyDelay(10) ;

        }

    }

  

    sprintf(str, "Error Count = %d\n", error_count) ;

    print(str) ;

          

    for(;;) {

        /* Place your application code here. */

    }

}

=========================

The result TeraTerm log was

4bit at the start

002-4bit-Start.JPG

4bit at the end

003-4bit-End.JPG

So at least for the 4bit A and B, DigiComp seems to be correct.

Then I tried 8bit, the result was

001-8bit-TeraTerm.JPG

in this test, I did not let the program print each lines, but Error Count was 0.

So even with 8bit A and B, DigiComp seems to be correct.

BTW, during this test, by mistake I fed 0x00 ~ 0xFF to 4bit A and 4bit B,

there I received a plenty of errors!

So may be you want to check if the bit width of your program and the DigiComp but width are matching.

moto

0 Likes

I created two eight bit control registers and compared them. All was fine but the case where the second was zero.

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

By any chance, can you test my comp_test_8bit sample?

It tests all A and B combination including 0 and in my environment no error was reported.

moto

0 Likes

I am avoiding use of zero. I will try to test yours. I will also try to retest mine. Perhaps i send you a snippet of logic.

If second operand is zero, should not any operand in first produce true result? It becomes don't care what is in first operand.

Any operand is greater or equal to zero.

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

(1) In my previous post my 8bit sample was testing only up to 0x0F for each A, B,

so I fixed them to up to 0xFF but there was no error reported. (comp_test_8bit)

(2) Then I connected 8 x Logic '0 's to B port of DigitalComp, but it caused PSoC Creator to be unable to compile.

Somehow Control_Reg for A ended up to be undefined. (this could be a bug, though...)

(3) Then I re-hired a Control_Reg for B and in the beginning of the  program I assigned 0 to Control_Reg for B

and looped A from 0x00 to 0xFF, this is the "case X >= 0" is tested.

And again no error was reported. (comp_test_8bit_op0)

So in general DigitalComp seems to be working.

But just like (2), there may be a combination which causes problem to PSoC Creator.

So your sample project which can re-produce the problem would be appreciated.

moto