Closed cosmok82 closed 11 years ago
The following sketch
HardwareSerial com;
void setup() {
// select the UART port (1-7):
com.selectModule(6);
// initialize serial communications at 9600 bps:
com.begin(9600);
}
void loop() {
}
compiles successfully on my Energia 010E0009 latest commit 1d9499cb31 with Tool > Board = StellarPad w/ LM4FH5QR
Binary sketch size: 2 860 bytes (of a 262 144 byte maximum)
Ok, the compile ends, but the relative UARTs don't communicate with the devices connected.
I used a bluetooth adapter with 3.3V logic level data pins (for TX and RX), but it show a return message only on serial "0" pins (on debug usb output) and not over all other pins, indepently if I set one serial communication or multi serials communication together.
How can I verify the correct communication? Could be a baud rate problem? or something else?
P.S. I set Tool > Board = StellarPad w/ LM4FH5QR on my Energia 010E0009 compiler.
I tested the communication on hardware uart, first I connected an uart to usb adaptor to read the transmitted signal output (and I didn't read never) after I connected a led in series with a resistor between vbus and TX uart, one at time for all TX uarts (and the led hasn't blinked).
This test work properly with serial "0" if I connect a wire on TXD hole on board, but not with all other ones.
I think that there's some error into compilation, in fact if I set two serial ports one of which is serial "0" (or Serial), neither of the two work; but if I set serial "0" and I comment the others all return to work (but on serial "0").
I use a x64 windows version, could be it the problem?
Do you have any answer for me?
HardwareSerial mySerial(0); Seem to be working OK (virtual serial on debug mode) but any other uart module number fails to transmit data. Fails => it seem that the uart buffer gets full and blocks all further code execution without ever emptying the buffer.
See additional information on #171
Sorry, but I still do not understand how you can use HardwareSerial, if try this
HardwareSerial mySerial;
void setup() {
mySerial.selectModule(6);
mySerial.begin(115200);
pinMode(RED_LED, OUTPUT); }
void loop() {
mySerial.write("helllo");
digitalWrite(RED_LED, HIGH);
delay(1000);
digitalWrite(RED_LED, LOW);
delay(1000);
} sketch compiling OK and upload. But then nothing happens, even the LED does not blink. This function work?
The function selectModule() is not really implemented in HardwareSerial.cpp.
I have some working code for serial, serial1 , serial2 Extract https://www.dropbox.com/s/pw25vi9ciki2476/lm4f.zip to hardware\lm4f\cores\lm4f\
here example of usage
HardwareSerial Serial1(1); HardwareSerial Serial2(2); void setup() { pinMode(RED_LED,OUTPUT); Serial.begin(9600); Serial1.begin(9600); Serial2.begin(9600); } void loop() { Serial.println("Hello world!"); Serial1.println("Hello world!"); Serial2.println("Hello world!"); delay(100); digitalWrite(RED_LED,HIGH); delay(100); digitalWrite(RED_LED,LOW); delay(100); }
Hello Michaels
We progress on the probleme, two Uarts OK!!!
i have tested your corrections on Uart drivers. Resulting hardware tests : Tx0 from Serial is OK. Tx1 from Serial1 is OK on PC_5(J4-36)
But TX2 from Serial2 is not OK on PD_7(J4-32) --> no outputs
What is strange: if HardwareSerial Serial2(2) is not here , you can not compile for Serial1
If you have news corrections i can do hardware tests very quickly.
TX0,TX1 work to 115200 bauds (Tested)
and Thanks for your Work JC
Hmmm , same trouble with serial2. Program not stopped , but nothing happens on GPIO_PD6_U2RX, GPIO_PD7_U2TX.
i just added code to check serial3 on GPIO_PC6_U3RX, GPIO_PC7_U3TX , works fine ... Checked all other serial ... not works.
So now i can use only
Serial - PA0 , PA1 Serial1 - PC4 , PC5 Serial3 - PC6 , PC7 Serial2 - PD6 , PD7 Not working Serial4 - PC4, PC5 Not working (same as Serial1?) Serial5 - PE4 , PE5 Not working Serial6 - PD4, PD5 Not working Serial7 - PE0, PE1 Not working
Thanks for the work. We are waiting for good news!! JC
Le 18/01/2013 12:17, michaelslobodskih a écrit :
Hmmm , same trouble with serial2. Program not stopped , but nothing happens on GPIO_PD6_U2RX, GPIO_PD7_U2TX.
i just added code to check serial3 on GPIO_PC6_U3RX, GPIO_PC7_U3TX , works fine ... I will check all other serial ports .
— Reply to this email directly or view it on GitHub https://github.com/energia/Energia/issues/165#issuecomment-12417879.
Tryed to make working uart2 with Code Composer Studio in uart-echo example (from stellarisware) Same problems ...
Uart0 - Works ok Uart1 - Works ok Uart2 - not works Uart4 - Works ok
I was just asking help on stellarisity forum http://forum.stellarisiti.com/topic/463-uart2-on-stellaris-launchpad/
I can not have binary file working if Uart3 initialized.
Do you have example on sketch with Uart0,1,3 activated.
Why HardwareSerial Serial2(2); must be declared to compile correctly
Serial1 ?
Thanks
Le 18/01/2013 15:17, michaelslobodskih a écrit :
Tryed to make working uart2 with Code Composer Studio in uart-echo example (from stellarisware)
Same problems ...
Uart0 - Works ok Uart1 - Works ok Uart2 - not works
Uart3 - Works ok
— Reply to this email directly or view it on GitHub https://github.com/energia/Energia/issues/165#issuecomment-12423445.
Try replace with this file https://www.dropbox.com/s/pw25vi9ciki2476/lm4f.zip
Serial2 not working because PD7 used for for VBUS detection when configured as a self-powered USB Device. So if u need working Serial2 , remove R15 (0ohm) and also need unlock PD7 change in \hardware\lm4f\cores\lm4f\main.cpp
HWREG(GPIO_PORTD_BASE + GPIO_O_CR) |= 0x8; to HWREG(GPIO_PORTD_BASE + GPIO_O_CR) |= 0x80;
Now Serial2 works :)
Thanks for the investigation.
Are you considering a pull request with your file https://www.dropbox.com/s/pw25vi9ciki2476/lm4f.zip?
Corrections from Michael are not complete in order to get acces to the UARTs 5-6-7. The interrupts vectors for Uarts 5-6-7 are not declared.
see my comments below: \lm4f\HardwareSerial.cpp : Warning !!!!! Ligne 127 uartModule = 2 must be uartModule = 0
Ligne 235 original is begin(baudRate) but baudRate is not passed in function Ligne 235 begin(9600) assume determined value
Add lignes 409-440:
409 void 410 UARTIntHandler1(void) 411 { 412 Serial1.UARTIntHandler(); 413 } 414 415 void 416 UARTIntHandler2(void) 417 { 418 Serial2.UARTIntHandler(); 419 } 420 421 void 422 UARTIntHandler3(void) 423 { 424 Serial3.UARTIntHandler(); 425 } 426 void 427 UARTIntHandler5(void) 428 { 429 Serial5.UARTIntHandler(); 430 } 431 void 432 UARTIntHandler6(void) 433 { 434 Serial6.UARTIntHandler(); 435 } 436 void 437 UARTIntHandler7(void) 438 { 439 Serial7.UARTIntHandler(); 440 }
Add lignes 441-448
441 //Preinstantiate Object (must be declared here and not in sketch) 442 HardwareSerial Serial(0);// prefered as HardwareSerial Serial; 443 HardwareSerial Serial1(1); 444 HardwareSerial Serial2(2); 445 HardwareSerial Serial3(3); 446 HardwareSerial Serial5(5); 447 HardwareSerial Serial6(6); 448 HardwareSerial Serial7(7);
\lm4f\startup_gcc.c : Add lignes 69-74
69 attribute((weak)) void UARTIntHandler1(void) {} 70 attribute((weak)) void UARTIntHandler2(void) {} 71 attribute((weak)) void UARTIntHandler3(void) {} 72 attribute((weak)) void UARTIntHandler5(void) {} 73 attribute((weak)) void UARTIntHandler6(void) {} 74 attribute((weak)) void UARTIntHandler7(void) {}
Modify line 117 :
117 UARTIntHandler, to UARTIntHandler1,
Modify line 144 :
144 UARTIntHandler, to UARTIntHandler2,
Modify line 170 :
170 UARTIntHandler, to UARTIntHandler3,
Modify line 172-174 :
172 UARTIntHandler, to UARTIntHandler5, 173 UARTIntHandler, to UARTIntHandler6, 174 UARTIntHandler, to UARTIntHandler7,
This sketch work fine:
void setup() { pinMode(RED_LED,OUTPUT);
Serial.begin(19200); Serial1.begin(115200); Serial2.begin(115200); Serial3.begin(115200); Serial5.begin(115200); Serial6.begin(115200); Serial7.begin(115200); }
void loop() { Serial.println("Hello world!"); Serial1.println("Hello world!"); Serial2.println("Hello world!"); Serial3.println("Hello world!"); Serial5.println("Hello world!"); Serial6.println("Hello world!"); Serial7.println("Hello world!"); delay(100); digitalWrite(RED_LED,HIGH); delay(100); digitalWrite(RED_LED,LOW); delay(100); }
I tested only Uart0 , Uart1, Uart 2 , Uart 3 , Uart 4. Uart 5 not work. I spend 90% of time with Uart2 with PD7 issue :) jcRBern - Yes my code not complete ,And you did it right :) I need some time to check all uarts , then i will write here again :)
the files keywords.txt in \lib must be updated to have the keyword serial 4,5,6,7 with blue color:
Serial5 KEYWORD3 Serial Serial5 KEYWORD3 Serial Serial6 KEYWORD3 Serial Serial7 KEYWORD3 Serial
Trying the both the basic [michaelslobodskih's] patch and the improved [jcR's], and the examples above code gets stuck when INITIALIZING all other serials other then 0... :/
Hello to all
I worked hard on serials communications for Stellaris Launchpad with Energia. I can now provide all the files for the correct operation of the card with the ports 0,1,2,3,5,6,7. And a test file with the corresponding wiring on the Launchpad. Unfortunately there is a major problem with the operation of ports in serial reception: You can not send a frame on a serial port in reception if you do not treat the reception of these frames. This causes software crash for the cards . Otherwise if the frames are received in time all UARTs work perfectly. How can i make this files available? Remark: it's not necessary to remove resistor R15 to work with Serial2 idem for Serial6 (USB) . you can work without modifs! JCR
Thank you for all your hard work!
The best way is to proceed with a pull request with your file as per the Bug fix and new feature review process.
2rei-vilo did u see my last post here https://github.com/energia/Energia/issues/148 ?
Sorry, I haven't seen it. The read only means you can't modify the master, hence the pull request system.
Fork the Energia project to your repository, edit the code, commit your work and them proceed with a pull request selecting Energia master as reference.
Hi i have uploaded my code (file MODIFS.zip) on Stellaristi forum in the general section. Sorry but i do no not understand correctly the general update system. Can you do it for me ( and especially for others) Thanks
See #181
@rei-vilo
Thanks for the work. jcr
Hello to all the file SerialHarware.cpp must be modified as described here:
// present code start at line 386 while(RX_BUFFER_FULL); rxBuffer[rxWriteIndex] = (unsigned char)(lChar & 0xFF); rxWriteIndex = ((rxWriteIndex) + 1) % SERIAL_BUFFER_SIZE;
//new code while(RX_BUFFER_FULL){ rxBuffer[rxWriteIndex] = (unsigned char)(lChar & 0xFF); rxWriteIndex = ((rxWriteIndex) + 1) % SERIAL_BUFFER_SIZE;}
this correct the overflow error in writing the reception ring buffer !!!!!!
I have opened a pull request.
jcr
Hi Rei-vilo it's not possible to close the issue 165. The workaround proposed by me is not correct!!!! I worked all day Sunday to find a solution. There has not for the moment. The pull request must be retired. Sorry for the inconvenience and the work I've done to you. The module SerialHardware.cpp has really a problem with the circular buffer management. If there is a buffer overflow then it causes a crash. The solution I have proposed is false, because it totally prevents reception of characters. Unfortunately, I was wrong by the following instructions:
while( RX_BUFFER_FULL);
(And this line should be removed because it is useless) The condition is never correct, due to bad implementation of circular Buffer.
In summary for now you should never send characters on a serial port without reception to prevent the buffer from filling more than (1024 bytes-1).
JC
I have fixed it with the following patch. When the RX buffer is full the byte is dropped by breaking out of the while loop. This keeps happing until the rx buffer is read from. The previous implementation would simply hang in an infinite loop. I have consolidate all the changes into commit b156c7f0a04c1cd38494d564621e51ddaa495bfe. Thanks @jcRBern for the changes and thank @rei-vilo for cleaning then up so that it was easy for me to consolidate them!
- while(RX_BUFFER_FULL);
+ uint8_t volatile full = RX_BUFFER_FULL;
+ if(full) break;
+
thank you very much to all!
jcRBern
The same issue seems to trouble me while interfacing EK-TM4C123GXL with bluetooth modules like HC05 and HM-10. The issue seems to arise in the UART communication. I didn't find any Issue on GitHub. Please Help.
Hi, I want to use the hardware serial on Stellaris Launchpad (the orange ones on schematic). I declared them with this implementation
HardwareSerial com;
void setup() { // select the UART port (1-7): com.selectModule(6); // initialize serial communications at 9600 bps: com.begin(9600); }
I tried it with all ports from 1 to 7, excluded port 0 and 6; but don't work. Do you have a solution?