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.

RTI Halco Gen example doesnt work and Question about Serial connections

Other Parts Discussed in Thread: HALCOGEN, LAUNCHXL2-570LC43

Hi guys,

i tried to get into the RTI. so i tried first the Halcogen example given in the help topics. But it seems that it doesnt work.

attached is my project.

I am using the TMS570LC43x (Launchpad LAUNCHXL2-570LC43).

Another question would be, Can i use the i2c, spi and rs232 connection on this board without booster package?
I have attached the pdf of the launching pad pin description. but i am little bit confused. And i would like to connect a temp.sensor to the i2c bus and send it to another board (Telit LE910 V2 EU) via Rs232 or SPI bus.

thanks in advance for your help.

best regards.

Markus

7103.rtiBlinky.zip4807.LaunchPad DevKit Pin description.pdf

  • Hello Markus,
    Can you please tell me what does not work? Which example did you try? Is it the example_rtiBlinky.c? This example tries to toggle the NHET1[0] pin every 1s. Normally on a HDK board you will see the LED blinking. On a launchpad the NHET1[0] is not connected to a LED. Is this what you meant as not working? If you use a scope you can probe the NHET1[0] pin on the J10 connector.

    All pins are accessible in different connectors. For example you can access I2C in J2 and J10 connectors. You just need to run some wires to these connectors.
  • Hello Charles,

    yes its rtiBlinky.c example. And indeed i thought that i see a blinking LED. Is it also possible to connect it to an LED ? For example can you tell me how i can see the blinking LED3 on GIOB_7?

    Sorry to ask again. if you look in the pdf there are the pins. on the J2 connectors (the 10 pin on the right side of the picture) i can only see GIOB3, GIOB2, N2HET1 and MIBSPI3.
    Or can you explain exactly where to find i2c?
    Because when i look on J1 i can see i2c on the last two pins. but over this column is written "BoosterPack standard". so where do i have to put my wires for SDA and SCL exactly??

    Thanks for your help.

    regards.

    Markus
  • Hi Markus,

     I modified the example and use the LED3 on the Launchpad for blinking. Please find attached.

    0044.LC4357_LP_LED3_Blinking.zip

    I will suggest that you look at the launchpad schematic to see the details. Due to the limitation of space not all signals are displayed in the starter guide. You can access the schematic from the launchpad wiki page at .

    Below is a snippet of J2 connector where you will also find I2C being multiplexed with MIBSPI3NCS_3/I2C1_SCL/N2HET1_29/NTZ1_1. The device datasheet terminal function table will also show what pins are muxed together. 

  • Hello Charles,

    can you tell me in which files you made modification that i can see the difference?

    and i am using the temperature sensor DS1621 (data sheet below).
    datasheets.maximintegrated.com/.../DS1621.pdf

    i wired now SDA to J2 Pin8 and SCL to J2 Pin9. GND to J2 Pin1 and Vdd to J1 Pin1.
    now i want to set up that the pin is used as i2c. where can i find it?
    and what do i need to program, that i can see data in my terminal?
    Right now i am trying to understand the halcogen example "i2c communication" but its not easy for me because i am new to this field.

    And what did you mean with device datasheet terminal function exactly?

    PS: And for later usage (i want to send the data over uart to another controller) can i use the J1 Pin 3+4 (SCI TX and RX) for the data transmission or is uart not possible?

    regards,

    Markus
  • Hi Markus,

     I created the project from scratch using HalCoGen following the halcogen rtiBlinky.c example just like you. The difference is that I modified it to use GIOB[7] instead NHET1[0]. Since you asked how to toggle LED3 and therefore the reason to change to GIOB[7] as GIOB[7] is connected to LED3 in the LaunchPad.  You should be able to simply just take my example_rtiBlinky.c and replace your HL_sys_main.c. All I change is inside the main() function. Everything else comes from halcoGen.

    If you go to the LC4357 datasheet terminal function table (see below), you will find that I2C1_SCL is muxed with MibSPI3NCS[3] and N2HET1[29]. MibSPI3NCS[3] is the primary function while the I2C_SCL and N2HET1[29] are the secondary function.

     To bring out I2c_SCL as the functional signal on the ball C3 you will need to steer the pin muxing. In HalCoGen, go to the PINMUX tab to bring out I2C. See below where I click the I2C1 box and the I2C1_SDA and I2C1_SCL will become the selected function on ball B2 and C3. 

    Yes, you can use the J1 pin3 and 4 as UART. Similar to I2C the UART is a secondary pin muxed with NHET1[6] and ePWM5A. To bring out SCI3 you will go to the PINMUX tab in HalCoGen and select SCI3 to bring out the UART functions. 

  • Hello Charles,

    Thanks for the detailed answer it helps me a lot! And the example works now. Thanks!
    Now i could see what you did there. I just don't know what you do with this line "gioREG->GCR0 = 1U".

    What is this U at the end i saw it many times?
    And where do i know i have to make this line?


    Also thanks for the help with the Uart and I2c example to show me how to select this functions!

    As i said i want to read the temperature from the sensor DS1621.
    Is it better to try to understand the example i2c communication or i2c master TXRX?

    My goal is to get the temperature of this sensor about every 5seconds, i want to send it first to my console or screen that i see i get the data and then i want to transmit this data via Uart to another controller. (And on the side i want that everytime data is sent that the led is blinking).
    I am little bit confused in which register i have to look and where to find the adresses and bits i have to set to receive this and send it to my screen.

    Can you help me with that, too?

    regards

    Markus

  • And can you send me link where i can download this "LC4357 datasheet terminal function datasheet" because i have only the data sheet with about 2000pages.

    regards
    Markus
  • Hi Markus,

    The gioREG->GCR0=1 is simply to release the GIO from reset. I could have just call gioInit() instead as it will also release the GIO from reset and configure the GIO based on your HalCoGen settings for GIO module.

    U is unsigned. The U has to do with the MISRA rule. “Rule 10.6 (required): A “U” suffix shall be applied to all constants of unsigned type.”

    I will suggest you start with example_i2c_pcf8570.c or example_i2cmaster_TX_RX.c as they are the examples that can be used to talk to an external slave device. The example_i2cCommunication.c setup the loopback mode. So it is talking to itself.

    Follow the example and you will see that the master (the MCU is the master and your temp sensor will be a slave) is receiving its data from the slave in the RX_Data_Master variable.

    Now you should follow example_sci_uart_9600.c on how to use the UART to send data to the terminal. You will need to modify it per your data coming from the i2c. The data you want to send to the terminal is in Rx_Data_Master.

    If you follow the two examples, I think you should be able to see the temp sensor data displayed on the terminal.
  • What you refer to is the TRM (Technical Reference Manual). Yes, it is over 2000 pages. :-)

    Below link is the corresponding datasheet.

    www.ti.com/.../spns195c.pdf
  • Hi Charles,

    thanks for this explanation though! it looked weird for me in the beginning because i am more used to "uint8_t" for

    ok do i understand it right:
    i2c:
    1) When i want to get data from the sensor i need the section "Master Receive Functionality". right?
    1.1) Or do i need both? to tell him first i dont want to send anything with the transmit function (so basically send the slave i NULL) !?

    2) i connect to the sensor via "i2cSetSlaveAdd(i2cREG1, slave_address)" and slave address is the address of the sensor. right?

    3) the i2cSetDirection-function tells him if the master (TMS570) wants to send/transmit or get/receive data. right?

    4) Why is the for loop limited for two loops?
    4.1) Is this the point what i have to modify if i want to receive every five seconds a new temperature?

    5) i2cSetCount is to count how long the data will be what i will receive. right?

    6) i dont get i2cSetMode. I write into the register of i2cREG1 the adress of the slave (temp.sensor) above with the function i2cSetSlaveAdd and then i write in the same register that this slave is a master?!? or do i have there a little mind problem?

    7) Why do they make the stop condition before the start condition and shouldnt be the stop condition always after the data was transmitted?

    8) i2cSend is the function where i should get the temperature data into the RX_data_master field. right?

    9) why do i have to wait exactly if the bus is still busy? isnt this a very fast microcontroller where by this little temp.sensor the data flow isnt really based on time? what i mean is that the data transfer is that fast that the bus is never busy too long.

    10) where and when will the "Stop" detected?


    uart:
    11) the example i only have to change "sciDisplayText(UART, &Rx_data_master[0], (sizeof)Rx_data_master)" and put the TEXT1,2,3 out because this is replaced with my temp.data. right?

    12) and in the function definition "void sciDisplayText(sciBASE_t *sci, uint8 *text, uint32 length)" below no changes need. right?

    ds1621:
    13) dont i have to make any settings by the temp sensor? what i mean is how do i get "23.5°C" and not for example 0x98 or 10011000 or anything else.

    PS: Sorry for maybe stupid questions but its my beginning with such a difficult microcontroller :(.

    PPS: the datasheet of the tempsensor i posted above in a comment.
    And for the UART i use CP2102 USB to UART Bridge. But i can connect to this COM-Port with the terminal.

    regards.

    Markus
  • 1) When i want to get data from the sensor i need the section "Master Receive Functionality". right?

    CT>> I'm not familiar with your DS1621 sensor. Does the sensor require the MCU to first set it up? Does the MCU need to write some commands to to the slave? If the MCU needs to first write some data to the slave then you will also need to Master Transmit functionality.

    1.1) Or do i need both? to tell him first i dont want to send anything with the transmit function (so basically send the slave i NULL) !?

    CT>> See answer above.

    2) i connect to the sensor via "i2cSetSlaveAdd(i2cREG1, slave_address)" and slave address is the address of the sensor. right?

    CT>> Yes.

    3) the i2cSetDirection-function tells him if the master (TMS570) wants to send/transmit or get/receive data. right?

    CT>> Yes.

    4) Why is the for loop limited for two loops?

    CT>> This is just an example. You can modify it per number of times you want to send/receive to/from the slave.

    4.1) Is this the point what i have to modify if i want to receive every five seconds a new temperature?

    CT>> Yes. 

    5) i2cSetCount is to count how long the data will be what i will receive. right?

    CT>> Yes.

    6) i dont get i2cSetMode. I write into the register of i2cREG1 the adress of the slave (temp.sensor) above with the function i2cSetSlaveAdd and then i write in the same register that this slave is a master?!? or do i have there a little mind problem?

    CT>> i2cSetMode tells that the MCU is a master or a slave. You want to set to master. The i2cSetDirection tells the direction of the transmission. A master can be either a transmitter or a receiver. A slave can also be a transmitter or a receiver. When the MCU is writing the data to the slave then the MCU is a master and a transmitter. When the MCU is reading the data from the slave then the MCU is a master but a receiver. The master is responsible for generating the clock even though it is only receiving the data.

    7) Why do they make the stop condition before the start condition and shouldnt be the stop condition always after the data was transmitted?

    CT>> The reason is that in this example it is in non-repeat-mode. In this mode the STOP bit is automatically generated after the number of data has been received or transmitted.  In this example, it first setup the number of data to receive as 10 in the i2cSetCount().

    8) i2cSend is the function where i should get the temperature data into the RX_data_master field. right?

    CT>> i2cReceive() is the function to receive the 10 data in RX_Data_Master variable.

    9) why do i have to wait exactly if the bus is still busy? isnt this a very fast microcontroller where by this little temp.sensor the data flow isnt really based on time? what i mean is that the data transfer is that fast that the bus is never busy too long.

    CT>> Which delay are you talking about? The while(i2cIsBusBusy(i2cREG1) == true) you are talking about? The processor is faster but the bus is slow like 100kbps. If the bus is still busy transmitting or receiving data then you don't want the CPU to initiate more writes to the bus.

    10) where and when will the "Stop" detected?

    CT>> See answer to 7. Please also refer to the userguide.

    uart:

    11) the example i only have to change "sciDisplayText(UART, &Rx_data_master[0], (sizeof)Rx_data_master)" and put the TEXT1,2,3 out because this is replaced with my temp.data. right?

    CT>> Yes. I will suggest that you play with the uart example first and make sure you can display something onto the terminal before integrating the i2c example.

    12) and in the function definition "void sciDisplayText(sciBASE_t *sci, uint8 *text, uint32 length)" below no changes need. right?

    >> Correct. You shouldn't need to modify.

    ds1621:

    13) dont i have to make any settings by the temp sensor? what i mean is how do i get "23.5°C" and not for example 0x98 or 10011000 or anything else.

    CT>> I don't have any experience with this part. Looks like coming form Maxim. You should read the corresponding datasheet or contact Maxim for support.

  • Hello Charles,

    thanks for all the answers.

    to display some stuff over the UART interface is no problem. it works good. But i have problems with the integration of the i2c data.

    The problem ist, when i go with debugging and breakpoints through my code it will be stuck in the i2cReceive Function at this point "while ((i2c->STR & (uint32)I2C_RX_INT) == 0U)" --> line 520 in "HL_i2c.c"

    i attached my project.

    Is the problem, that there are no data which i can receive? or what is the problem?

    regards,

    Markus

  • Hi Markus,
    The MCU is not receiving the data from the temp sensor. You need to use the scope to debug the problem. First of all, do you have proper pullup resistor on the I2C bus? Use the scope to view the SCL and SDA bus? Does the temp sensor reply the (ACK bit) acknowledge when the MCU sends the command?
  • Hi charles,
    maybe for the sensor i will go to the other forum or ask later again.

    For now i am trying to send "hello" to the terminal when i press button on giob4 and "world!" when i press button giob5.
    But i want that when i press the button giob4 it should also turn on the led2 so giob6 and when i press giob5 it should turn on led3 so giob7.

    But the only thing what happens is that it sends hello and world to my terminal but the leds stays turned off.
    and i want that it sends the text everytime when i press the buttons only once(!) and the led should be turned on thhttps://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/312/7457.LED_5F00_SCI.7ze whole time i press. so when i press the button giob4 first time it should print hello in the terminal and the led should turn and when i press the second time after 10 seconds (for example) it should send another (a second) hello and the led should turn on again.
    Can you look at my code and tell me maybe where my mistake is?

    PS: you have to look also in "TransUart.h" to get the structure.

    regards,

    Markus

  • sry the file got into the text. (Its "LED_SCI.7z").

    regards,
    Markus
  • Quickly looked at your code. You said you want to turn on GIOB[6] when GIOB4[4] is pressed. Shouldn't you do below instead.

    buttonStatus = gioGetBit(gioPORTB, 4)? 1:0; // set Pin

    gioSetBit(gioPORTB, 6, buttonStatus); // turn off / on LED

  • hi charles,


    no i have another project where i only use this without uart. just the buttons and leds and its working that only when i press the led goes on.


    and i have a third project where i can send some chars or strings with uart to the terminal.

    but its strange that this is not working if i put the two together (the code what i have sent).

    and i cant find the reason ...

    regards,
    Markus
  • Hi Markus,

     You didn't set the pin direction to output for GIOB[6] and GIOB[7]. Add below line hightlighted in red and you should see the LED. I tried and and it works.

    gioInit();

    gioSetDirection(gioPORTB,0xC0);

    sciInit();

  • One more thing is that you need to use SCI1 in order to communicate with the terminal via the COM port. I modified your code and see the display like below.

  • hi Charles,


    perfekt now it is working. such a simple thing! Thanks.
    Can you explain me how you come on the hex 0xC0? is it because you only set Pin 6 & 7 to logical 1 so "output"? its 1100 0000 right?

    i didnt get your second post. I dont have problems to send something to the terminal, the problem was just to have both, uart communication in terminal and blinking LED. :).

    Another question can you help me with i2c?
    Because i tried to make the first "example_i2cMaster_TX_RX.c" from halcogen. but if i make the settings i dont see anything. and the code is all the time in i2cSend function in a infinite while loop.
    I also tried to put an logic analyzer on this sensor and when i tried this example there was no falling edge or something by the data. so i think its something with the settings from Halcogen and i2c bus and (right now) not with the communication.

    regards

    Markus

  • Hi Markus,
    Glad it is working for you now. Yes, 0xC0 is only to enable GIOB[7:6] as output.

    Do you have external pull up resistor on the I2C bus?
  • Hi Charles,

    sorry to answer that late. wasnt here over the end of the week and weekend.

    i upload a picture how i wired the sensor to the board.

    And in just in case. How can it be possible to use i2c (for the sensor) and spi (communication to another device) at the same time?
    Because in halcogen it says to me that there are conflicts with mibspi3_cs2 and 3. Is it possible?
    and in general, when i want to use spi. how can i connect spi with the laptop?

    regards,

    Markus

  • Hi Markus,

      It depends if you really need the MibSPI3NCS[3] and MibSPI3NCS[2] in your SPI communication. If you can do away without the NCS[3:2] in your SPI communication using SPI3 then you can still have both SPI3 and I2C at the same time. For SPI3 you just don't NCS[3:2].

      There is no direct hookup to communicate SPI to PC. Perhaps you need a USB to SPI converter or UART to SPI converter so you can the COM port to talk to the SPI.

  • hi charles,

    what usage can be needed the MibSPI3NCS[3] and MibSPI3NCS[2]?

    and is the connection above with the sensor and the i2c right?

    regards,

    Markus
  • Hi Markus,

    If your SPI3 is a master and you want to talk to multiple slave SPI devices then you can use different chip select for different slave. If you don't have such intention then you don't need to worry about nCS[3:2]. Just make sure in your SPI3 configuration you will not use nCS[3:2].

    I don't see anything wrong with your i2c connection.
  • Hi Charles,

    so if my workaround is that i have a sensor connected to i2c to the MCU and an lte modul (like TELIT LE910 EU V2) connected via sci or spi (so its basically only one master (the ti board) and only two slaves which are (sensor and lte module) is then one chip select enough?
    so the pin3 on J2 would be MIBSPI3NCS_1 that i use only this one?

    I2C:
    you said above something about "external pull up resistor". thats why i asked. my sensor is a DS1621 temperature sensor.

    regards,
    Markus
  • Hi Markus,
    I'm not familiar with TELIT LE910 but I quickly read its datasheet and its SPI interface is only 3-wire. You should check with TELIT for confirmation. Otherwise it should work. You can use the MCU as the master talking to the I2C and the TELIT LE910 as slaves. You don't need chip select. Again check with TELIT.

    I2C requires pullup resistor on the bus. You must have pullup resistor on both the SCL and SDA lines or it will not work. You can do google search to understand how I2C protocol works. Here is one example link:
    www.i2c-bus.org/.../