gr8going 0 Posted March 31, 2016 Share Posted March 31, 2016 Hi experts!! I'm a beginner and working on CC3200 LP along with Energia IDE. I'm working on a simple project where I've an external device which has RS485 o/p and I need to fetch the values in specified addr location in that device to CC3200 LP. My doubts are #1) we have external module that has device ID+parameter Address and we need to transmit the value in LP through UART, here I'm not sure how to use the UART function to specifically target device+address and return/get the same.... #2) what I'm looking/exploring is that in above example (UART code which Andy shared here ) what function specifically reads DeviceID+parameter Addr and returns that string value to my LP My experiments: I've been checking uart.h file and following lines looks close to what I need to do - but not sure... extern void UARTConfigSetExpClk(unsigned long ulBase, unsigned long ulUARTClk, unsigned long ulBaud, unsigned long ulConfig); extern void UARTConfigGetExpClk(unsigned long ulBase, unsigned long ulUARTClk, unsigned long *pulBaud, unsigned long *pulConfig); I'm planning to have my framework Energia sketch might be like calling below functions in specified order 1) UARTIntClear ==> to initialize/clear in LP 2) UARTIntEnable ==> enable UART of my LP 3) UARTConfigSetExpClk ==> to set what I need to read from the external device to my LP 4) UARTConfigGetExpClk ==> to GET what I need to read from the external device to my LP 5) perform step 1 to 4 after 5 sec ==> loop it Am I missing something in above flow?? My Setup I've installed Tera Term in my PC to monitor com port I've got Rs485 to RS232/TTL converter which can be connected to my cc3200 LP UART PIN_02, PIN_01 (RX_1 & TX_1) ... or nay other UART pin which is applicable. my external device which has RS485 o/p ==> Baud rate of 9600, Parity = Even, Device Address = 1, Stop bit = 1, Data type = 32 bit float real, Data to be red from address (Float) 3913, 3909, 3903, 3965, please advice Quote Link to post Share on other sites
chicken 630 Posted April 1, 2016 Share Posted April 1, 2016 RS-232 and UART do not support device addressing. You will have to find out how your adapter translates the RS485 protocol to basic serial. The easiest is probably to fist try to use a USB-to-serial adapter with your RS-485 adapter and a terminal program on a computer to figure out how to talk to your device. Without that basic understanding it will be almost impossible to write the software. The manual of your adapter might also provide some information. The UART calls you reference above are low-level calls into TI libraries to initialize the UART peripheral and don't do what you described after "==>". I assume you go that deep because Energia does only support 8N1 (i.e. 8 bit, parity = none, stop = 1). If your serial converter really requires even parity, then you'll have to edit HardwareSerial::begin in hardware/cc3200/cores/cc3200/HardwareSerial.cpp and modify this call: MAP_UARTConfigSetExpClk(UART_BASE, 80000000, baudRate, (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE | UART_CONFIG_WLEN_8)); Regards, Adrian gr8going 1 Quote Link to post Share on other sites
gr8going 0 Posted April 6, 2016 Author Share Posted April 6, 2016 Hi Adrian Thanks a lot for your reply. I'll surly use your suggestion of changing the UART_CONFIG_PAR_NONE to UART_CONFIG_PAR_EVEN. Yes as you said, I used USB/485 adaptor and learnt that I should be using 485 library on top of HardwareSerial.cpp which creates a wrapper to generate protocol packets and planned to read from external device to my cc3200. My External Device (slave) : that has RS485 o/p from which we can tap the register values and it works on ModBus protocol. cc3200 (master): using UART (TX and RX) com port.. Using Energia for flashing. Now, before deep diving I did some sample/long experiments and following is what I observed. Case 1: Flashed my cc3200 for slave having some reg values. configured my ModBus master simulator to receive the value from my cc3200 slave. Connection: Case 1.A cc3200 through USB => computer COM port + ModBus master simulator :: Result PASS / could see change in values in my ModBus simulator Case 1.B cc3200 UART (P57 Tx and P55 Rx) => through converter TTL/232 => 232/485 converter => USB/485 converter => computer COM port + ModBus master simulator :: Result FAIL ( No values received.. CheckSum error TimeOut etc.,) Here I've powered cc3200 with external USB portable battery. Since my Case 1.B failed I just tried two simple experiment below (case2 & 3) case 2 cc3200 flashed with simple Serial.print "A & 8" ==> and saw the results in my Laptop/Tera Term (COM port console) :: Result success Case 3 cc3200 with simple Serial.print "A & 8" flashed ==> through converter TTL/232 => 232/485 converter => USB/485 converter ==> Laptop/Tera Term (COM port console) :: Result Failure Could see some ASCII prints but not sure why is that ... Please guide me to understand what I'm missing Regards, Ranga Quote Link to post Share on other sites
chicken 630 Posted April 6, 2016 Share Posted April 6, 2016 As direct connection worked but converters does not, I'd assume a configuration mismatch somewhere in the converter chain. E.g. what baud rate, bit count, parity, stop configuration does the TTL/232 or 232/485 converter expect? What parameters do you need to set in TeraTerm to talk 485? I can't help you with both, as I'm not familiar with RS-485. gr8going 1 Quote Link to post Share on other sites
gr8going 0 Posted April 6, 2016 Author Share Posted April 6, 2016 Thanks .. Will update once I figure out what's going wrong ... For now all parameter(s) like baud rate, connections (Tx to Rx and Rx to Tx etc.,) looks okay... BTW, I changed my HardwareSerial.cpp lines to MAP_UARTConfigSetExpClk(UART_BASE, 80000000, baudRate, (UART_CONFIG_PAR_EVEN | UART_CONFIG_STOP_ONE | UART_CONFIG_WLEN_8)); And it's working under EVEN parity now... Regards, Ranga Quote Link to post Share on other sites
gr8going 0 Posted May 29, 2016 Author Share Posted May 29, 2016 Case 3 cc3200 with simple Serial1.print "A & 8" flashed ==> through converter TTL/232 => 232/485 converter => USB/485 converter ==> Laptop/Tera Term (COM port console) :: Result Failure Update>> The above did not work (may be) the USB/485 converter is bad or I was missing something ... But when I modified above conversions as below through converter TTL/232 => 232/USB converter => Laptop/Tera Term (COM port console) :: Result PASS I used Serila1 which is P01 and P02 in CC3200 LP Till today I'm still NOT clear why other serial (say TX(0) or RX(0) ) which is mentioned in block diagram did not help me Quote Link to post Share on other sites
dubnet 238 Posted May 29, 2016 Share Posted May 29, 2016 If you have a logic analyzer, or can borrow one, then you can see what the signals look like at each point in the chain. Without being able to see where a problem is possibly being introduced by one of the converters, you are shooting in the dark. gr8going 1 Quote Link to post Share on other sites
gr8going 0 Posted May 30, 2016 Author Share Posted May 30, 2016 If you have a logic analyzer, or can borrow one, then you can see what the signals look like at each point in the chain. Without being able to see where a problem is possibly being introduced by one of the converters, you are shooting in the dark. I agree! Since I dont have logic analyszer.. I'm forced to do trial and error After many trials finally I got work around .. so now my circuit looks like CC3200 -> UART1 (Serial1) -> TTL/232 -> 232/485 -> external device which has RS485 Where Serial1 = P01 and P02 But I was expecting to have below connection which did not work CC3200 -> UART (Serial) -> TTL/232 -> 232/485 -> external device which has RS485 Where Serial = P03 and P04 Any ways .. thanks for reading and suggestion! Love this forum ! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.