FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Show Posts

You can view here all posts made by this member. Note that you can only see posts made in areas to which you currently have access.

Messages - willycat

Pages: [1]
1
Discussion - Software / Another bug found in the Vinc compiler.
« on: August 24, 2021, 03:08:46 PM »
Hi,

if you compile the file below the same way as in my previous post:

Quote

/*********************************************************************************
*********************************************************************************/

rom unsigned char DevsDefs[] =
{
   0x08, 0x10, 0x00, 0x01, 0x00, 0xe6,
};

unsigned short vID;
unsigned long idx;

/*********************************************************************************
*********************************************************************************/

void main(void)
{
   for (;; );
}

/********************************************************************************/
/********************************************************************************/

void cmd_def()
{
   vID = (DevsDefs[idx++] << 8 ) | DevsDefs[idx++];
}

/********************************************************************************/
/********************************************************************************/


it will produce this incorrect code between the 0x00440 and 0x0048a addresses:

Quote

003c0 fa00 03e0           JUMP 0x003e0
003c2 fa00 03c0           JUMP 0x003c0
003c4 fa00 03be           JUMP 0x003be
003c6 fa00 03c0           JUMP 0x003c0
003c8 fa00 03c0           JUMP 0x003c0
003ca fa00 03c0           JUMP 0x003c0
003cc fa00 03c0           JUMP 0x003c0
003ce fa00 03c0           JUMP 0x003c0
003d0 de00 0000 0000 0000 CMP32 0x0000 $0x00000000
003d4 0000                NOP
003d5 0000                NOP
003d6 0000                NOP
003d7 0000                NOP
003d8 2e78               
003d9 7a79               
003da 0000                NOP
003db 0000                NOP
003dc 0000                NOP
003dd 0000                NOP
003de 0000                NOP
003df 0000                NOP
003e0 b028 0001           OUTPORT 0x028 $0x01
003e2 bc00 3ffc           INPORT 0x000 0x3ffc
003e4 3204 3ffc           SHR8 0x3ffc $0x04
003e6 da01 3ffc           CMP8 0x3ffc $0x01
003e8 fa40 0408           JNZ 0x00408
003ea b00f 0000           OUTPORT 0x00f $0x00
003ec b080 0012           OUTPORT 0x080 $0x12
003ee b088 000f           OUTPORT 0x088 $0x0f
003f0 b089 00f0           OUTPORT 0x089 $0xf0
003f2 b084 0000           OUTPORT 0x084 $0x00
003f4 b085 0000           OUTPORT 0x085 $0x00
003f6 b08a 00ff           OUTPORT 0x08a $0xff
003f8 b08b 003f           OUTPORT 0x08b $0x3f
003fa b081 0001           OUTPORT 0x081 $0x01
003fc c883 0000           PORTTST 0x083 $0 Z
003fe fa40 03fc           JNZ 0x003fc
00400 b080 0000           OUTPORT 0x080 $0x00
00402 b088 0000           OUTPORT 0x088 $0x00
00404 b089 0000           OUTPORT 0x089 $0x00
00406 b083 00ff           OUTPORT 0x083 $0xff
00408 2600 3ffa 0916 0000 LD32 0x3ffa $0x00000916
0040c 3201 bffa           SHR32 0x3ffa $0x01
0040e 2400 3ffe 0000      LD16 0x3ffe $0x0000
00411 2400 3ff8 001e      LD16 0x3ff8 $0x001e
00414 3201 7ff8           SHR16 0x3ff8 $0x01
00416 dc00 3ff8 0000      CMP16 0x3ff8 $0x0000
00419 fa1c 042a           JLE 0x0042a
0041b 2d01 3ffa 3ffe      CPYROM (0x3ffe) 0x3ffa $01
0041e 6c00 3ffe 0002      ADD16 0x3ffe $0x0002
00421 6e00 3ffa 0001 0000 ADD32 0x3ffa $0x00000001
00425 6c20 3ff8 0001      SUB16 0x3ff8 $0x0001
00428 fa00 0416           JUMP 0x00416
0042a 2600 3ffc 0000 0000 LD32 0x3ffc $0x00000000
0042e 2600 3ff8 0000 0000 LD32 0x3ff8 $0x00000000
00432 0a00 0000           SP_LOAD $0x0000
00434 fa00 043d           JUMP 0x0043d
00436 0000                NOP
00437 0000                NOP
00438 0000                NOP
00439 0000                NOP
0043a 1008               
0043b 0100                CPYF Z Z
0043c e600               
0043d fa00 043d           JUMP 0x0043d
0043f 0006                RTS
00440 f200 800c           PUSH32 0x000c
00442 f200 8010           PUSH32 0x0010
00444 2600 0004 0001 0000 LD32 0x0004 $0x00000001
00448 3e00 8004 0020 000c SHR32 0x000c 0x0020 0x0004
0044c 2600 0010 043a 0000 LD32 0x0010 $0x0000043a
00450 7400 8010 000c      ADD32 0x000c 0x0010
00453 2c01 000c 0000      CPYROM 0x0000 0x000c $01
00456 fa52 045a           JNF1 0x0045a
00458 3208 4000           SHR16 0x0000 $0x08
0045a 4400 0000 0010      CPY8 0x0010 0x0000
0045d 4400 0010 0000      CPY8 0x0000 0x0010
00460 4e00 0000 00ff 0000 AND32 0x0000 $0x000000ff
00464 2600 0004 0008 0000 LD32 0x0004 $0x00000008
00468 3e20 8004 0000 0010 SHL32 0x0010 0x0000 0x0004
0046c 2c01 000c 0000      CPYROM 0x0000 0x000c $01
0046f fa52 0473           JNF1 0x00473
00471 3208 4000           SHR16 0x0000 $0x08
00473 4400 0000 000c      CPY8 0x000c 0x0000
00476 4e00 000c 00ff 0000 AND32 0x000c $0x000000ff
0047a 5440 8010 000c      OR32 0x000c 0x0010
0047d 8201 8020           INC32 0x0020 $0x01
0047f 8201 8020           INC32 0x0020 $0x01
00481 8201 8020           INC32 0x0020 $0x01
00483 4400 400c 001e      CPY16 0x001e 0x000c
00486 f380 0010           POP32 0x0010
00488 f380 000c           POP32 0x000c
0048a 0006                RTS
0048b 0000                NOP
0048c 0000                NOP
0048d 0000                NOP
0048e 0000                NOP
0048f 0000                NOP
00490 0000                NOP
00491 0000                NOP
00492 0000                NOP
00493 0000                NOP
00494 0000                NOP
00495 0000                NOP
00496 0000                NOP
00497 0000                NOP
00498 0000                NOP
00499 0000                NOP
0049a 1808               
0049b 150f               
0049c 2438 e4d7 0025      LD16 0x24d7 $0x0025

The idx variable is incremented by 3 instead of 2.
The second jnf1 instruction should be jf1 and it lack of a second shr32 instruction.


Willy.

2
Discussion - Software / Re: BUG found in the VinAsm tool ?
« on: August 24, 2021, 01:26:33 PM »
Hi,

to replicate this issue, compile this file:

Quote
/*********************************************************************************
*********************************************************************************/

#define HOST_DD1 0x01
#define HOST_DD2 0x02
#define HOST_DR1 0x04
#define HOST_DR2 0x08
#define HOST_DEV 0x40
#define HOST_DSK 0x80

#define NUMBER_OF_DEVICES 6

#define GPIO_A_5 2
#define GPIO_A_6 3

/********************************************************************************/

typedef struct _BSS_t
{
   // Hardware type
   unsigned char hwType;
   // Hardware version
   unsigned char hwVersion;
   // Swap order LEDs
   unsigned char swapActivityLeds;
   // Device type bitmap for USB ports 1
   unsigned char host1DevType;
   // Device type bitmap for USB ports 2
   unsigned char host2DevType;
   // Devices state
   unsigned char devsState;
   // State of monitor LEDs
   unsigned char monLEDsON;
   // Sate of Individual monitor LEDs
   unsigned char monLEDsState;

} BSS_t;

/********************************************************************************/
/********************************************************************************/

unsigned char msk1;
unsigned char msk2;
unsigned char msk3;
unsigned char msk4;
unsigned char msks1;
unsigned char msks2;

BSS_t *BSS;

/*********************************************************************************
*********************************************************************************/

void main(void)
{
   for (;;);
}

/********************************************************************************/
/********************************************************************************/

void cmd_cr()
{
   msk1 = HOST_DD1;
   msk2 = HOST_DD2;
   msk3 = HOST_DR1;
   msk4 = HOST_DR2;

   msks1 = (HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2);
   msks2 = ~(HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2);

   BSS->devsState &= ~(HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2);
}

/********************************************************************************/
/********************************************************************************/


using the following commands:

VinC.exe -c -d 1 -O 4 -o Debug\USB-BUG.asm USB-BUG.c

VinAsm.exe -v -d 1 -o Debug\USB-BUG.obj Debug\USB-BUG.asm

VinL.exe -d 1 -o Debug\USB-BUG Debug\USB-BUG.obj

and you will obtain this file with the bug:

Quote
003c0 fa00 03e0           JUMP 0x003e0
003c2 fa00 03c0           JUMP 0x003c0
003c4 fa00 03be           JUMP 0x003be
003c6 fa00 03c0           JUMP 0x003c0
003c8 fa00 03c0           JUMP 0x003c0
003ca fa00 03c0           JUMP 0x003c0
003cc fa00 03c0           JUMP 0x003c0
003ce fa00 03c0           JUMP 0x003c0
003d0 b500 0000           OUTPORT 0x100 0x0000
003d2 0000                NOP
003d3 0000                NOP
003d4 0000                NOP
003d5 0000                NOP
003d6 0000                NOP
003d7 0000                NOP
003d8 2e78               
003d9 7a79               
003da 0000                NOP
003db 0000                NOP
003dc 0000                NOP
003dd 0000                NOP
003de 0000                NOP
003df 0000                NOP
003e0 b028 0001           OUTPORT 0x028 $0x01
003e2 bc00 3ffc           INPORT 0x000 0x3ffc
003e4 3204 3ffc           SHR8 0x3ffc $0x04
003e6 da01 3ffc           CMP8 0x3ffc $0x01
003e8 fa40 0408           JNZ 0x00408
003ea b00f 0000           OUTPORT 0x00f $0x00
003ec b080 0012           OUTPORT 0x080 $0x12
003ee b088 000f           OUTPORT 0x088 $0x0f
003f0 b089 00f0           OUTPORT 0x089 $0xf0
003f2 b084 0000           OUTPORT 0x084 $0x00
003f4 b085 0000           OUTPORT 0x085 $0x00
003f6 b08a 00ff           OUTPORT 0x08a $0xff
003f8 b08b 003f           OUTPORT 0x08b $0x3f
003fa b081 0001           OUTPORT 0x081 $0x01
003fc c883 0000           PORTTST 0x083 $0 Z
003fe fa40 03fc           JNZ 0x003fc
00400 b080 0000           OUTPORT 0x080 $0x00
00402 b088 0000           OUTPORT 0x088 $0x00
00404 b089 0000           OUTPORT 0x089 $0x00
00406 b083 00ff           OUTPORT 0x083 $0xff
00408 2600 3ffa 08c4 0000 LD32 0x3ffa $0x000008c4
0040c 3201 bffa           SHR32 0x3ffa $0x01
0040e 2400 3ffe 0000      LD16 0x3ffe $0x0000
00411 2400 3ff8 001e      LD16 0x3ff8 $0x001e
00414 3201 7ff8           SHR16 0x3ff8 $0x01
00416 dc00 3ff8 0000      CMP16 0x3ff8 $0x0000
00419 fa1c 042a           JLE 0x0042a
0041b 2d01 3ffa 3ffe      CPYROM (0x3ffe) 0x3ffa $01
0041e 6c00 3ffe 0002      ADD16 0x3ffe $0x0002
00421 6e00 3ffa 0001 0000 ADD32 0x3ffa $0x00000001
00425 6c20 3ff8 0001      SUB16 0x3ff8 $0x0001
00428 fa00 0416           JUMP 0x00416
0042a 2600 3ffc 0000 0000 LD32 0x3ffc $0x00000000
0042e 2600 3ff8 0000 0000 LD32 0x3ff8 $0x00000000
00432 0a00 0000           SP_LOAD $0x0000
00434 fa00 043a           JUMP 0x0043a
00436 0000                NOP
00437 0000                NOP
00438 0000                NOP
00439 0000                NOP
0043a fa00 043a           JUMP 0x0043a
0043c 0006                RTS
0043d f200 800c           PUSH32 0x000c
0043f f200 8010           PUSH32 0x0010
00441 2201 0020           LD8 0x0020 $0x01
00443 2202 0021           LD8 0x0021 $0x02
00445 2204 0022           LD8 0x0022 $0x04
00447 2208 0023           LD8 0x0023 $0x08
00449 220f 0024           LD8 0x0024 $0x0f
0044b 22f0 0025           LD8 0x0025 $0xf0
0044d 2400 000c 001e      LD16 0x000c $0x001e
00450 4401 400c 000c      CPY16 0x000c (0x000c)
00453 8205 400c           INC16 0x000c $0x05
00455 4401 000c 0010      CPY8 0x0010 (0x000c)
00458 4a30 0010           AND8 0x0010 $0x30
0045a 4500 0010 000c      CPY8 (0x000c) 0x0010
0045d f380 0010           POP32 0x0010
0045f f380 000c           POP32 0x000c
00461 0006                RTS
00462 0000                NOP
00463 0000                NOP
00464 0000                NOP
00465 0000                NOP
00466 0000                NOP
00467 0000                NOP
00468 0000                NOP
00469 0000                NOP
0046a 0000                NOP
0046b 0000                NOP
0046c 0000                NOP
0046d 0000                NOP
0046e 0000                NOP
0046f 0000                NOP
00470 0000                NOP
00471 1808               
00472 150e               
00473 1014               
00474 d182
               

Willy.




3
Discussion - Software / BUG found in the VinAsm tool ?
« on: August 22, 2021, 11:31:39 AM »
Hi

I wasted my time to try to found why my code is not working properly and the reason seems to be your VinAsm tool.

Look at this piece of my code:



Quote

...

typedef struct _BSS_t
{

   ...
   unsigned char devsState;
   ...

} BSS_t;

...

BSS_t *BSS;

...

unsigned char msk1;
unsigned char msk2;
unsigned char msk3;
unsigned char msk4;
unsigned char msks1;
unsigned char msks2;

...

void cmd_cr()
{
   msk1 = HOST_DD1;
   msk2 = HOST_DD2;
   msk3 = HOST_DR1;
   msk4 = HOST_DR2;

   msks1 = (HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2);
   msks2 = ~(HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2);

   BSS->devsState &= ~(HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2);
}

...


The compilation process produce a code which seems correct to me in the ".asm" generated file:

Quote

.FUNCTION   "cmd_cr"   

.RETURN "void"   0   0   0   3   0   0   0   
PUSH32   %r0
PUSH32   %r1
.LINE   56
LD8   msk1   $1
.LINE   57
LD8   msk2   $2
.LINE   58
LD8   msk3   $4
.LINE   59
LD8   msk4   $8
.LINE   61
LD8   msks1   $15
.LINE   62
LD8   msks2   $240
.LINE   64
LD16   %r0   $BSS
CPY16   %r0   (%r0)
LD16   %ebx   $280
ADD16   %r0   %ebx
CPY8   %r1   (%r0)
AND8   %r1   $240 <-----
CPY8   (%r0)   %r1
.LINE   64
POP32   %r1
POP32   %r0
RTS   
.FUNC_END   "cmd_cr"



Look especially at the marked line: $240 = 0xf0 which is effectively ~(HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2)

But when i take a look at the disassembler file genereted during debugging, i find this which explain why my code doesn't work:


Quote

158ee f200 800c           PUSH32 0x000c
158f0 f200 8010           PUSH32 0x0010
158f2 2201 03af           LD8 0x03af $0x01
158f4 2202 03b0           LD8 0x03b0 $0x02
158f6 2204 03b1           LD8 0x03b1 $0x04
158f8 2208 03b2           LD8 0x03b2 $0x08
158fa 220f 03b3           LD8 0x03b3 $0x0f
158fc 22f0 03b4           LD8 0x03b4 $0xf0
158fe 2400 000c 03ad      LD16 0x000c $0x03ad
15901 4401 400c 000c      CPY16 0x000c (0x000c)
15904 2400 0004 0118      LD16 0x0004 $0x0118
15907 7400 4004 000c      ADD16 0x000c 0x0004
1590a 4401 000c 0010      CPY8 0x0010 (0x000c)
1590d 4a30 0010           AND8 0x0010 $0x30 <-----
1590f 4500 0010 000c      CPY8 (0x000c) 0x0010
15912 f380 0010           POP32 0x0010
15914 f380 000c           POP32 0x000c
15916 0006                RTS


0x03ad is the address of the BSS pointer. 0x118 is the offset of the devsState member in the BSS_t structure.

Look especially at the marked line: 0x30 is not 0xf0 and then is not ~(HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2) !

Is this a known bug ?

Apparently, this is a problem with the &= operator: If i replace

Quote
BSS->devsState &= ~(HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2);

by

Quote
BSS->devsState = BSS->devsState & ~(HOST_DD1 | HOST_DD2 | HOST_DR1 | HOST_DR2);

i obtain this code:

Quote

15951 2400 0014 03ad      LD16 0x0014 $0x03ad
15954 4401 4014 0018      CPY16 0x0018 (0x0014)
15957 2400 0004 0118      LD16 0x0004 $0x0118
1595a 7400 4004 0018      ADD16 0x0018 0x0004
1595d 4401 4014 0014      CPY16 0x0014 (0x0014)
15960 2400 0004 0118      LD16 0x0004 $0x0118
15963 7400 4004 0014      ADD16 0x0014 0x0004
15966 4401 0014 0014      CPY8 0x0014 (0x0014)
15969 4400 0014 0000      CPY8 0x0000 0x0014
1596c 4e00 0000 00ff 0000 AND32 0x0000 $0x000000ff
15970 2600 0014 fff0 ffff LD32 0x0014 $0xfffffff0
15974 5400 8000 0014      AND32 0x0014 0x0000
15977 4500 0014 0018      CPY8 (0x0018) 0x0014


which works but is badly optimized.

Willy.



4
Discussion - Software / Re: I2C with VinculumII
« on: June 28, 2021, 01:37:53 PM »
OK, i found the mistake !

i incorrectly configure the pins for the i2c interface: they need to bi bidirectional.

Quote
// i2c interface
vos_iomux_define_bidi(14, IOMUX_IN_GPIO_PORT_B_2, IOMUX_OUT_GPIO_PORT_B_2);
vos_iomux_define_bidi(15, IOMUX_IN_GPIO_PORT_B_3, IOMUX_OUT_GPIO_PORT_B_3);


Now, it works.

It is normal for the vos_dev_read() function to begin with a write operation to update the address pointer of the i2c slave.

Thanks.

5
Discussion - Software / Re: I2C with VinculumII
« on: June 27, 2021, 10:09:41 PM »
Hi,

thank you for your reply. My confusion came from the "i2c.h" file which talk about pin number starting at one.

Things go better now as there is activity on clock and data signals, but it doesn't work yet. Look at this source code:


Quote
   #define VOS_DEV_I2C 5

   // Configure direction of port B
    vos_gpio_set_port_mode(GPIO_PORT_B, 0x0c);

    // i2c interface
    vos_iomux_define_output(14, IOMUX_OUT_GPIO_PORT_B_2);
    vos_iomux_define_output(15, IOMUX_OUT_GPIO_PORT_B_3);

    // Needed declarations
    i2c_ioctl_cb_t i2c_iocb;
    i2c_port_t i2c_port;
    unsigned char i2cerr;

    char i2c_Buf[8];
    uint16 i2c_Nbr;

    VOS_HANDLE hI2C;

    // Define the I2C pins
    i2c_port.clkPort = I2C_PORT_B;
    i2c_port.clkPortNo = 3; // Pin 15
    i2c_port.dataPort = I2C_PORT_B;
    i2c_port.dataPortNo = 2; // Pin 14
    i2cerr = i2c_device_init(VOS_DEV_I2C, &i2c_port);

    // Open I2C Interface
    hI2C = vos_dev_open(VOS_DEV_I2C);

    // Set RTC address
    i2c_iocb.ioctl_code = VOS_IOCTL_I2C_SET_DEVICE_ADDRESS;
    i2c_iocb.data = 0x68;
    i2cerr = vos_dev_ioctl(hI2C, &i2c_iocb);

    // Set I2C options
    i2c_iocb.ioctl_code = VOS_IOCTL_I2C_SET_OPTIONS;
    i2c_iocb.data = I2C_OPTIONS_READ_ADDRESS;
    i2cerr = vos_dev_ioctl(hI2C, &i2c_iocb);

    // Set address to read
    i2c_iocb.ioctl_code = VOS_IOCTL_I2C_SET_RDWR_ADDRESS;
    i2c_iocb.data = 0x00;
    i2cerr = vos_dev_ioctl(hI2C, &i2c_iocb);

    // Read one byte form Addess 0x00
    i2cerr = vos_dev_read(hI2C, i2c_Buf, 1, &i2c_Nbr);


First: All vos_dev_ioctl() calls return 1. From what i saw in the disassembly code window, this is normal and each call successfully did its job. But according to the manual, the vos_dev_ioctl() function should return 0 in case of success.

Second: The vos_dev_read() fail and return 2. With my scope, i know that the first byte (which contain the start condition,the chip address, the direction bit) is sent to the RTC which response with an ACK. But that is all i see and the R/W bit is set to 0 instead of 1 for a read.

I tried to find where the problem could be in the assembler code, but your debugger doesn't allow to put breakpoint in the assembler code which makes the debug process almost impossible.

Maybe, i do something wrong, but i don't know what.

In attachment, you will find the result of the vos_dev_read() function.

Can you help me again ?

Thanks.

6
Discussion - Software / I2C with VinculumII
« on: June 16, 2021, 05:29:32 PM »
Hi,

I would like to use an RTC chip with the VinculumII via an i2c interface.

But where is the documentation of the "i2c.a" library ? Only one function is referenced in the "i2c.h" file of the VinculumII toolchain ("i2c_device_init") but nothing else.

Thanks,

Willy.

Pages: [1]