Jump to content
43oh

RobertWoodruff

Members
  • Content Count

    37
  • Joined

  • Last visited

Everything posted by RobertWoodruff

  1. Yes, that had occurred to me as well. If this app was awake at all times that would be easier to implement. But this one spends most of its life in LPM3 (it is a battery powered system). I am too lazy to want to complicate the for loop with logic to see if LPM3 should be delayed or not because a human user is awaiting a response. It is just easier to send the response during the RX ISR routine and let the system fall back into LPM3 when the RX ISR terminates. Essentially the for loop is not running most of the time, if that makes sense. Thank you,
  2. The replies make good points, thank you. I am going to look into disabling the RX ISR while the command is being processed within the RX ISR. That fits within the use-cases for this app. hopefully the HC-05 BT module has enough buffering to hold any few characters that may come in while RX ISR is disabled. Another option is to place the commands in a queue to be processed "later" when not in the RX ISR. Without an OS to support queueing, threading and scheduling issues that is just too much trouble, for this project on this little MCU (running out of code space anyway) Thank you for t
  3. This is a recap of a little adventure in the hopes that it helps someone else out there. This application is on an MSP430G2553 MCU. CSS is used as the IDE and the Energia libraries are in play (a good tooling combination, highly recommend J). The app spends most of its time in LPM3. It wakes up periodically to do certain tasks and also wakes up when traffic comes in on the UART RX channel. The ISR for the RX channel detects the arrival of a command and acts on the command during the ISR. Part of servicing a command is sending a response, which is transmitted via the UART TX channel
  4. The "secret" to having the compiler/linker erase/set the flash memory when a program is flashed in has been solved. In CSS right-click on the project and select Properties. Select Debug then MSP43x Options. In there select under Erase Options "Erase main and information memory." Now whenever a new program is flashed to the MCU the SEGMENTB, C, and D are initialized to 0xFF in every byte. Perfect! Hope this helps someone else out there!
  5. Hi Bob, Your app looks doable to me, though not trivial. The hardware connections and interfaces are straight forward to make work for your prototype. Of course, moving the h
  6. Hi Bob, I use CSS with the Energia libraries (CSS now has explicit support for Energia). It is a reasonable choice, you can
  7. I had come across this article as well and it looks to have the answers. In my attempts to use the CCS #pragma statements the compiler warns it does not recognize them. Hopefully it is a setting somewhere that will let them work. Still researching. Thank you for the effort!
  8. My recommendation is to use the Energia Setup()/Loop() construct, And use CCS as the IDE rather than the Energia IDE. CCS is Eclipse and so the its debugger can be used.. Without the debugger progress will be tough. LPM3 is encapsulated in Energia by the sleep() methods so you make sleep() calls rather than LP3 directly. I have the MCU to respond to traffic on the UART RX channel while in LPM3 by processing the requests during the RX ISR wakeup. Thank you,
  9. I have had good success with using Energia libraries via Code Composer Studio for the TI MSP430. And for low power, interrupt driven application needs. Energia is a framework/libraries that help with some of the nitty stuff. And you have the source to Energia which helps with learning. I have made my own version of certain Energia modules, specifically to extend them to help with event driven needs You are right that it is C++. It always amazes me that we can use full object oriented C++ on these little MCUs. But we can. Classes, encapsulation, methods, and so forth. The UARTs work we
  10. I have figured out how to use flash memory to persist values in the MCU, like to survive across a power failure. So that is cool. One last thing is how does one get the CCS C++ compiler/linker to initialize a flash segment? Does anyone have a technique for initializing a segment? For example, I am mapping the persistent values into SEGMENT_C. The C++ compiler/linker does not, at least as mine is setup, initialize the flash segment. It always has the same values from the last time the program wrote values in there, even when the program is rebuilt and reloaded into the MCU. I have b
  11. Hi Roboticus, You are correct, the parameter values to AT+CLASS= are hex numbers. There is a overview in the Bluetooth spec about formatting and interpreting the 32 bit class value (CoD). I am not going to learn all that now but have learned enough to carry forward with this application. Here is a translation between what is sent to the AT command and what is seen on the Android side /* Android Java code segment */ BluetoothClass bluetoothClass = btDevice.getBluetoothClass(); int deviceClass = bluetoothClass.getDeviceClass(); int majorDeviceclass = bluetoothClass.getMajorDeviceCl
  12. Has anyone figured out how to translate the value supplied to the HC-05 Bluetooth module's AT+CLASS= command to the value that is retrieved on the far end from the Bluetooth device connection? I can find explanations of how the individual bits of a standard BT 32 bit class value are to be interpreted. But I cannot figure out how to encode that value in the HC-05's AT+CLASS= command nor how any value set there translates to the value picked up when doing the BT paring on the far end. For example, if pairing with an Android the Java code on the Android to retrieve the class is something
  13. RX can be monitored by watching, with the CSS debugger, what characters are coming in from the UART interrupts being placed in the "ring_buffer" (HardwareSerial.cpp in Energia). They can also be reliably seen by watching, again with the debugger, the traffic to your serialEvent routine. It is a little tricky because the debugger sort of interferes with the ISRs used to capture the RX traffic. /* * From BT device on UART */ void serialEvent(void) { while(Serial.available()) { int cInt = Serial.read(); /* fetch next char from the UART buffer */ command.addChar(cInt); if (command.
  14. Hi, again, tripwire, Let me ask, what is the difference between these two statements 1. String aStr = String("abc"); 2. String *aStr = new String("abc"); Is this this: In stmt 1 when aStr goes out of scope ~String is called and the object is deleted/freed. In stmt 2 when aStr goes out of scope the object remains allocated and no destructor call?
  15. Hi tripwire, Thank for for the explain. Programming on the TI MCU has brought me back to C++ for the first time in quite a long while (mostly use Java and its JRE on larger platforms). It is interesting getting reacquainted with C++ memory management. Thanks!
  16. That sounds reasonable, not inclusive, Certainty easy enough to use it that way. I usually think of the parameters of substring to be ::substring(start, length). In any event, thank you to the person(s) that wrote this library. It is most useful!!
  17. The char set to 0 is restored to the original buffer rather than the new buffer. So the new buffer does not get the right most character. Kind of feels like a bug?
  18. This is the substring method of the String library in Energia. 1 String String::substring(unsigned int left, unsigned int right) const 2 { 3 if (left > right) { 4 unsigned int temp = right; 5 right = left; 6 left = temp; 7 } 8 String out; 9 if (left >= len) return out; 10 if (right > len) right = len; 11 char temp = buffer ; // save the replaced character12 buffer = '\0'; 13 out = buffer + left; // pointer arithmetic 14 buffer = temp; //restore character15 return out; 16 } Line 12: Tha
  19. The only way I could figure how to develop the code to interface Launchpad (with single UART MCU) and HC-05 was to download and use CSS on Windows. Otherwise there is just not an effective way to debug what is happening between the MCU and HC-05. Now with all that plumbing in place it is impressive what can be accomplished with the MCU as a control processor and the HC-05 as the means of external communication with the controller. (We are also building an Android app as the human interface to the control system. The Android communicates to the MCU via the BT connection). Try to get CSS
  20. FYI, I use Windows with CSS and the Energia libraries. It is not generally possible to use serial monitor when the HC-05 connected as there is but one UART on the MCU (assuming your Launchpad has a MSP430G2x53 MCU). I use the CSS debugger to monitor the traffic on the UART RX channel (be careful though as the debugger messes up the ISR (interrupt service routines)). Also it is a good idea to connect the HC-O5 WAKEUP pin to something to pull it high to place the HC-05 into AT mode. Pull it low the HC-05 goes to communication s mode. The HC-05 accepts an AT command to place it into s
  21. Believe I have this figured out. It is the CSS debugger that interferes with the ISR routines. When the debugger is sitting at a breakpoint it keeps the ISRs from firing as expected which has the effect of causing input to the UART RX channel to appear to fall in the bit bucket. Not unexpected really by virtue of the way the debugger works. The delay() call gave the IRS routines time to absorb all the responses before the debugger break point was reached. That is good news really, Because now we know that UART input continues to be accepted even when a delay() call is active. So be
  22. Hi Chicken, That is all the code I wrote. The remainder is in the Energia libraries for TI (for the MSP430G2 LaunchPad). I get the bytes from the UART with the statement int cInt = Serial.read(); Somehow, without the delay call, not all the bytes are delivered back to serialEvent(void). I can see this by watching the calls to serialEvent(void) via the Code Composer Studio debugger. Wonder why the call to delay() lets all the info return to the UART, but without the delay() only some of the response gets back? It is like the ISR was/is disabled or something and the return traffi
  23. Hi Chicken, Yes I understand that response from the Serial communications is not instantaneous.. My thinking is that with the traffic on the UART RX being processed by an ISR (interrupt service routine) that the incoming characters would be delivered to serialEvent(), eventually (at least that is how it looks to me in the Energia source code). And that the response characters might not all come in at once but be delivered to serialEvent(), in dribs and drabs, in the future. Eventually, when the program detects the /r/n pattern it would know the response was complete. It is like the
  24. I now have an HC-05 Bluetooth board and it works better than did the HC-06. RX is to TX and TX is to RX. VCC and GND are connected to the Launchpad. The
×
×
  • Create New...