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.

Help.. How configure GPIO port A to send 8 Bit data ?

Other Parts Discussed in Thread: TMS320F28027, CONTROLSUITE

Hello.

I am using 28027 C2000 Launch pad, I need to interface LCD display with my Launch pad. The LCD required 8bit data interface to communicate.

I can see C2000 have 32bit port and can not send 8bit data to the port.

I could not find any application note for 8 bit data transfer with C2000.

Please share any sample code or guide to do 8 bit data transfer in C28027.

Thank you

  • Hi Rafeeq,

    You don't have ready-made lcd header files for TMS320F28027, you have to create one. BTW which lcd are you using ? If its 16x2 or 16x4 do check this post for more info http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/210923.aspx

    Regards,

    Gautam

  • Hello Mr. Gautham,

    Thank you very much for your response.

    I am trying to interface 2x16 LCD.

    I think (but not 100% sure) firmware not too complex in 8bit mode.

    I could not find how to send 8 bit data in 28027 or any TMS320 micro controller.

    If you have any sample code for similar function or 8bit data transfer sample code, kindly share with me.

    Thank you.

  • Dear Gautham,

    I have gone through the link provided in your reply, It is very detailed and informative, however I am still not clear how to configure and send 8 bit data to GPIO pins .

    I already made wiring and interfacing circuit as per one tutorial from google.

    28027 have 32bit in port A GPIO and all instruction and commands are to address either BIT or "all" 32bit.

    I already searched in many application notes and TMS320 user guides , no success, Could you help me about this ?

    I need some information how to send 8bit and 16bit data to respective GPIO pins with out disturbing other GPIOs configured for other function.

    I am sorry, i am new to TMS 32bit controller.

    Thanks

  • Sorry Rafeeq, you'll have to wait till Monday. BTW; I was fed up developing the driver for 16x2 LCD -  F28335 interfacing; all in vain. Finally I'm using an 8bit PIC controller for display and communicating with my master controller F28335 using SPI/SCI protocol. Happy with the performance :)

     

    Regards,

    Gautam

  • Hello Gautam,

    Thank you for reply. I will be waiting for your guidance and comments.

    After seeing your reply, I am really interested to look in to the PIC option you have suggested, but I do not have PIC programmer.

    but I need to work on TI controller right now, PIC option later.

    Thank you.

  • Rafeeq,

    I think your 8-bit writes will look something like:

    Uint32 somedata;

    GpioDataRegs.GPADAT.all = somedata & 0x000000FF; //write to GPIO7-GPIO0   

    GpioDataRegs.GPADAT.all = (somedata << 8) & 0x0000FF00; //write to GPIO15-GPIO8   

    GpioDataRegs.GPADAT.all = (somedata << 16) & 0x00FF0000; //write to GPIO23-GPIO16

    GpioDataRegs.GPADAT.all = (somedata << 24) & 0xFF000000; //write to GPIO31-GPIO24   

    This method is going to be a little inefficient; you may want to find the address of half of a GpioDataReg and write to that instead.  Note that using this method you do not necessarily have to write to byte-aligned set of GPIO, e.g. you could write to GPIO29-GPIO22, but the 8 GPIO do have to be numbered consecutively.

    If you are writing to 8 non-consecutive arbitrary GPIO, you will need to have an elaborate mess of bit unpacking and routing. 

  • Hello Devin,

    Thank you for reply.

    You are right, I need to write to GPIO29-GPIO22 individual bits consecutively, and not byte-aligned value.

    I have nearest GPIOs configured some other output functions, which are not suppose to be disturbed.

    I believe find how to bit unpack 8 bit data and need to write to address of GPIO DATA REG.

    Please correct me if any other method is available, or give me some idea about the explained method.

    Thank you.

  • Hello Devin,

    I made a quick C code to unpack bit value of decimal quantity from its bit position.

    Each bit can be extracted and used to control corresponding GPIO pins.
    But code need to be still modified for each bit in byte value.

    Hope this will work to control individual GPIOs controlling.

    My Idea is to check status of each bit using the C code given below, and accordingly control the GPIO by "bit" set/reset command.

    Please give your advice, I checked the code separately but I am not sure this will work in Code composer studio.


    int main(void) {
      int bit_n;
      int bit_pos;
      int byte;
      //
      byte = 64;       // input data in byte
      bit_pos =6;    // bit position to check high/low
      //
    unsigned char mask_table[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };

    bit_n = ( byte & mask_table[ bit_pos ] ) != 0x00;

     printf("%d\n", bit_n);        // return the value of bit in "bit_n" position.
     
      return bit_n;
    }
     
      

  • Hi Rafeeq,

    Once you have the data into the variable "byte", I believe your code will work to check the individual bits. 

    You bring up an important point about my above code: it will incorrectly clear the other GPIO.  You would actually want to do a read-modify-write, and you would want it to be atomic with respect to any other code that might change the GPIO on port A in an interrupt.   

    Instead of read-modify-write, you could use set and clear instructions.  It might look something like:

    Uint32 data; //lower 8-bits are data to be written, upper 24 bits are all 0s.

    GpioDataRegs.GPASET.all = (data << 20);

    GpioDataRegs.GPACLEAR.all =  ((~data) & 0x000000FF) << 20;

    This would have the possible disadvantage of having delay between when some bits go high and the others go low. Instead, you could do:

    Uint32 olddata; //the current data on the 8-bit port of GPIO29-GPIO22, either read from the GPADAT bits or cached from the last write.  Lower 8 bits are data, upper 24 bits are 0s

    Uint32 data; //lower 8-bits are data to be written, upper 24 bits are all 0s.

    GpioDataRegs.GPATOGGLE.all = (olddata ^ data) << 20; 

    Note that I have not actually compiled/validated the above, but this should give you a general idea.

  • Dear Rafeeq MUHAMMED:
    Have u got the result
    As I am also working on interfacing 16x2 LCD interface with TMS320F28027 luachpad
    But I am not getting results
    can u help me
  • Hello Ashutosh,

     

    I changed processor due to other reasons, so not much worked on 28027, also successfully interfaced LCD.

    I have verified individual port bit control method will work as I explained in my earlier post, thanks to Devin for help :-)

    If you like to continue same controller you may refer my reply where I mentioned technique of bit polling and set/reset each port bit of LCD data line. This method will workout after couple of trial and error.

    Since 28027 have 32bit port direct access (sending integer value directly to port) may interfere other port lines you might have assigned for other purpose.

    Let me now if you need further support.

    RAFEEQ

     

     

  • Hey Rafeeq,

    Great to know that you were able to do it! If possible do share the drivers if still available with you. It would be helpful for other thousands of members who seek for similar queries on the forum.

    FYI Ashutosh:
    BTW I've developed a dedicated Comm board itself that is interfaced with GLCD, wireless comm, USB comm, EEPROM comm etc :) and all this is taken care by a dedicated controller that keeps communicating with C2000 mcu via SPI.
    In this way all my control algorithms work smoothly and are not interrupted!
    Previously I interfaced Serial LCD with C2000 mcu using SCI... this made me write huge menu driven codes in C2000 mcu itself. It was very successfully done.... but its super complex ie the menu flow with so many flags.

    Regards,
    Gautam
  • Rafeeq,

    Please check Parallel_Boot.c code in F28027 boot rom available in controlsuite in the path shown below. This should be be a great starting point

    controlSUITE\libs\utilities\boot_rom\2802x\2802x_boot_rom_v2_0


    Regards,

    Manoj