This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HTU with 2 N2HET programs

Hello,

I have 2 N2HET program (A and B). I had to cut down a bigger program in 2 because of the limitation on the number of instructions.

Thus, A and B have 1 instruction in common that enable HTU transfer, but this instruction is not at the same address in both program.

In my sys_main this is what I do:

 - Setup every registers and peripheral (N2HET, DCP of HTU,...)

- load program A in the N2HET RAM

- run the program A

- Wait until I have received the required number of data transferred by the HTU

- disable the N2HET

- Load program B in the N2HET RAM

- disable HTU, and re-configure the DCP with the new address of the instruction in the program B, then enable HTU again

- Run program B

Result:

When I look into the buffer after the program A, the HTU has correctly transferred the number of data I was expected to receive.

but the HTU seems to be disabled for the second program.

Do you have any idea on how I can implement this, when I try to modify the DCP, nothing happens

thank you

Brice

  • What I have seen is that the N2HET address in IHADDR of the IHADDRCT register of the HTU RAM is not updated properly with the new address of the N2HET instruction.
    I don't figure out why for the moment.
  • Hello:

    I will direct your question to one of our experts to provide some feedback.

    Regards.
  • Hello Brice,

      You are saying that you tried to write to the IHADDR with the address for the 2nd N2HET program but the IHADDR still remains with the address for the first N2HET program? Is this the correct understanding?

      Can you check if you are in privilege mode or in user mode when you try to write to IHADDR for program B? The register is privilege mode protected. 

  • Hello Charles,

    Thank you for your reply,

    Actually when I was modifying the IHADDR with the second address, the register was updated badly, the value in the memory was not reflecting the address.

    I have to memset the htuRAM1 with 0, before trying to reconfigure the DCP to get the good address value in the register. What is strange is that all other registers in the DCP registers configuration memory are updated correctly.

    Brice

  • Hi Brice,

      What about other fields in the same register like DIR, SIZe, ADDMH and etc? Are they updated corrected?

      Can you also do an expeiment by starting with program B first and followed by program A? In this case will you see program A address not getting set correctly in the IHADDR?

  • Hi,
    I cannot tell you with certitude that all these field are updated correctly, since I don't modify them.
    However, I modify the Address of the buffer A (to continue where it has stopped to be filled at the end of the program A) and this address is modified correctly.
    I also modify the IFTCount and it gets updated as well.

    hereafter the value in my DCP at initialisation (for the prog A)

     DCPConfig.AddrBufferA = (uint32)RecoveryTimeIBuff_P1; //record address of the initial buffer
     DCPConfig.AddrBufferB = (uint32)NULL;
     DCPConfig.DCPNumber = 0; //DCP 0
     DCPConfig.DirectionTx = 0; //from N2HET to Main Memory
     DCPConfig.Size = 0; //32-bit data
     DCPConfig.ADDMH = 0;
     DCPConfig.ADDMF = 0; //post-incr
     DCPConfig.TMBA = 0; //0= one shot transfer, 1 = circular, other value = auto switch
     DCPConfig.TMBB = 2; // not used anyway
     DCPConfig.IHADDR = (NHETAdressProgA*4)+2;//NHET address field ------------> this is equal to 402(dec) for program 1
     DCPConfig.ITCount = 1; //1 elem of 32-bit
     DCPConfig.IFTCount = 29 ; //29 frames


    .... Here I initialise the NHET, HTU, DMA MIBSPI and whatever I need in my Main
    I load and run program A (N2HET program)
    wait for its end
    ...
    then
    disable the N2HET device, load program B, enable the N2HETdevice (program B is looping between 2 BR instructions waiting for the Main program to modify the conditional address of one of the BR instruction)

    at this stage this is what I have in the htuRAM 1:

     0x080015EC is the correct address of my buffer A, 0x0 for address of buffer B (no buffer B used)

    0x00020648  where the 2 is the value of TMBB and NHETAdress = 648(hex) >>2  = 402(dec) this is correct

    0x0001001D where 1D  = IFTCount  = 29 and IETCOUNT =1 correct.

    0x08001660 is actually pointing to the address of the next transfer.

     Then

    DisableTHTU ();

    DCPConfig.AddrBufferA = (uint32)(RecoveryTimeIBuff_P1+29); //record address of the initial buffer ----> 0x08001660

    DCPConfig.IFTCount = 30; //31 frames

    DCPConfig.IHADDR = (NHETAddProgB*4)+2;//NHET address field ------------> should be 358(dec)

    HTUInit();

    SetDoubleControlPacket(0, TRUE, FALSE); // enable a single buffer A for DCP 0

    // The DCP0 configuration in HTU RAM needs to be cleared before setup a new DCP0 configuration

    //memset((void*)(htuRAM1),0, 4*4);

    ConfigureDCP(DCPConfig);

    EnableTHTU ();

    This is now what I have in the htuRAM1:

    AddrBufferA is correctly updated,

    IFTCOUNT and IETCOUNT as well,

    but IHADRR not:

    0x000207D8: 2 is still the value of TMBB ok

    NHETAddress = 7D8(hex) >>2  = 502(dec) wrong !!!

    if I uncomment out the memset on the htuRAM, my NHETAddr is correctly updated.

    If I a slot I will try to invert as you asked the program A with B. But I don't see why it would work better.

    regards,

    Brice

  • seems that the pictures of the htuRAM content have not been embedded properly in my previous message
  • Hello Charles,
    I found the problem,
    and I am a bit confuse. It is all my mistake, off course.
    When I made the diff between both value obtain in the register I realised that in my function that set the register of the nhetaddrr I used an OR.
    this result in some bits are not cleared properly.
  • Hello Brice,
    Glad that you catch the problem before me. I was just looking at your code.