Menu

i need help with read and write function in c#

2019-06-07
2019-10-17
1 2 > >> (Page 1 of 2)
  • Mourad hosni

    Mourad hosni - 2019-06-07

    -sorry for my english
    im using hidlibrary c#
    i have problem configuring the size of the eprom spi in the loop
    hid work like this send 64 byte packet receive 64 byte packet
    and i have problem receiving all packet together and substract 4 byte from each packet
    thats all for the moment

    this is the loop for reading eprom
    Task t = new Task(async () =>
    {

                for (i = 0, w = 0; i < bufferF.Length; w++)
                {
                   // bufferF[w++] = 0;
                    bufferF[w++] = SPI_READ;
                    bufferF[w++] = 0x3C; // i < mybyt.Length - (DIMBUF - 2) ? DIMBUF - 2 : mybyt. - i;
                    bufferF[w++] = FLUSH;
                    for (; k < eeprom.Size +4; k++)
                    {
                        HidReport first3 = new HidReport(64, new HidDeviceData(bufferF, HidDeviceData.ReadStatus.Success));
                        device.Write(bufferF);
                        device.ReadReport(ReadSpiContent);
    
                    }
                    // bufferU[w] = 0x0;
                    //if (bufferL[1] == SPI_READ && bufferL[2] < 0xFA)
                    //{
                    //    for (z = 3; z < bufferL[2] + 3 && z < DIMBUF; z++) memEE[k++] = bufferL[z];
                    //}
    
                    //await device.ReadReportAsync(bufferF.Length);
    
                }
            });
            t.Start();
    
            for receiving i use tyhis function
    
                public void ReadSpiContent(HidReport SpiContent)
        {
    
            byte[] managedArray = new byte[SpiContent.Data.Length];
    
        }
    
     
  • Mourad hosni

    Mourad hosni - 2019-06-11

    got it working thx anyway , but i have problem receiving full size of eprom, can i modify src of the pic 18fxxx to send all content of eeprom without 0X3C thx

     
  • Alberto Maccioni

    Sorry, I don't understand the context.
    Are you re-writing opgui in c#?
    What EEPROM?

     
  • Mourad hosni

    Mourad hosni - 2019-06-13

    yes and il make it opensource

     
  • Mourad hosni

    Mourad hosni - 2019-06-13

    im begginning with spi flash

     
  • Mourad hosni

    Mourad hosni - 2019-06-13

    not exactly re-writing or tranlating code, another concept

     
  • Mourad hosni

    Mourad hosni - 2019-06-13

    u are genius with c++

     
  • Alberto Maccioni

    The sources are plain C

     
  • Mourad hosni

    Mourad hosni - 2019-06-15

    openprog 9.1

     
  • Alberto Maccioni

    That version is obsolete, you should look at opgui 10.1

     
  • Mourad hosni

    Mourad hosni - 2019-06-21

    plz can you help me to do something :
    i need a Case : wehn i send SPIREAD to Pic it read total size of eprom;
    because i have problem with hidlibrary ,when i read incoming data from PIC ,my hidlibrary read in the separat function (Hidreport report)and i cant do 2 loop 1 for readind and one for receiving data ; thx
    any help WELCOME.

     
  • Mourad hosni

    Mourad hosni - 2019-06-21

    case SPI_READ:

     
  • Anonymous

    Anonymous - 2019-09-20

    help to write parallel flash memory

     
  • Alberto Maccioni

    Parallel flash requires a lot of IO lines, so the current hardware would need a port expander of some sort.
    I am currently not planning anything like this.

     
  • Anonymous

    Anonymous - 2019-09-30
    i need only help with pic function,  im doing that with 74hc595 , just a little help for advancing
    thx
    
     
  • Alberto Maccioni

    So you have some hardware; what does it look like?
    Please post a schematic diagram.
    What IO lines are you planning to use?

     
  • Mourad hosni

    Mourad hosni - 2019-10-01

    This is schematic thx

     
  • Mourad hosni

    Mourad hosni - 2019-10-01

    eeprom 27c 29xxx 28xxx dedicated project
    thx

     
  • Mourad hosni

    Mourad hosni - 2019-10-01

    in the futur im planning to use 74hc165 for input expander

     
  • Alberto Maccioni

    I see, you have some port expanders for addresses and direct connection for data.
    One thing you should do to make it compatible with the current programmer is using RA3-4-5 instead of RC0-1-2 for the expanders.
    Then you also have RC6-7 available. I am pretty sure you need additional control signals in order to read or write parallel memories, like WE, CE, OE etc.
    On the software side, an immediate option is to use instructions WRITE_RAM and READ_B/READ_AC in order to access those ports, however for performance reasons it would be better to implement a new WRITE_EXP_PORT that quickly shifts the desired data to the port expanders.

     
  • Mourad hosni

    Mourad hosni - 2019-10-07

    This is my test reading 1 byte from address 0xF0, 27c64
    Sorry can you tell me more about WRITE_RAM ,you have 1 example
    thx

     
  • Mourad hosni

    Mourad hosni - 2019-10-07

    im using CCS thx

     
  • Alberto Maccioni

    I can't read your code from the image.
    Anyways, an example of READ_RAM can be found in opgui.c, function IOchanged(GtkWidget widget,GtkWidget window)
    ....
    bufferU[j++]=READ_RAM;
    bufferU[j++]=0x0F;
    bufferU[j++]=0x80; //PORTA
    ...
    Here you read PORTA at address 0x0F80.
    After PacketIO(2) you will find in the return packet:
    ... READ_RAM, 0x0F, 0x80, [content of PORTA] ...
    In the same functions you can find examples of WRITE_RAM as well.

     
  • Mourad hosni

    Mourad hosni - 2019-10-11

    thx
    but now i have problem reading 8 or 16 byte in the loop
    this is my function for reading from 74165 parallel serial

    void write_expanded_outputs(unsigned int8 *eo)
    {
    unsigned int8 i;
    output_low(EXP_OUT_CLOCK);
    #if EXP_OUT_RCLK != EXP_OUT_CLOCK
    output_low(EXP_OUT_RCLK);
    #endif
    output_low(EXP_OUT_ENABLE);

    for(i=0;i<(NUMBER_OF_74595*8);i++) // Clock out bits from the eo array
    {
    if(bit_test(eo[NUMBER_OF_74595 - 1], 7) == 0)
    output_low(EXP_OUT_DO);
    else
    output_high(EXP_OUT_DO);

      shift_left(eo,NUMBER_OF_74595,0);
    
      output_high(EXP_OUT_CLOCK);
      output_low(EXP_OUT_CLOCK);
    
     #if EXP_OUT_RCLK != EXP_OUT_CLOCK
      output_high(EXP_OUT_RCLK);
      output_low(EXP_OUT_RCLK);
     #endif
    

    }

    #if EXP_OUT_RCLK == EXP_OUT_CLOCK
    output_high(EXP_OUT_CLOCK);
    output_low(EXP_OUT_CLOCK);
    #endif

    output_high(EXP_OUT_ENABLE);
    output_low(EXP_OUT_ENABLE);
    }

    the loop go infinite i have tryed all
    BYTE buffer[BUFFSIZE]; //64
    BYTE readeprom(){
    BYTE data2;
    int offset;
    for (offset = 0; offset < 8;offset++){ //address from 0x00 to 0x07
    write_expanded_outputs2 (&offset);
    read_expanded_inputs (buffer);
    }
    data2 = buffer;
    return data2;
    }

    then function to send to pc
    usb_put_packet(1, readeprom(), 64, USB_DTS_TOGGLE);

     
  • Alberto Maccioni

    I have no idea of what you are doing.
    Is this source is from your porting in C++?
    I only know about opcodes sent to the porogrammer.
    What does output_high/low do?

     
1 2 > >> (Page 1 of 2)

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.