chipKIT® Development Platform

Inspired by Arduino™

Max32 Serial read problem

Created Sun, 25 Aug 2013 07:40:18 +0000 by Ian Billing


Ian Billing

Sun, 25 Aug 2013 07:40:18 +0000

Hoping someone can assist me. I am trying to read the serial in on Rx1 but as soon as any data arrives at the Rx1 pin my whole loop freezes. I have a wire from Tx1 to Rx1 and, as soon as I remove the wire, my loop runs fine and data transmits. As soon as I connect the wire to Rx1 it freezes up. Even if I do not read Rx1 the same applies. Just the arrival of data at the Rx1 pin causes the hang up.

Any help is greatly appreciated.

unsigned tStart = 0; unsigned tWait = 1500; int intSteps=1;

void setup(){

Serial.begin(9600); Serial1.begin(9600); Serial.println("RS232 Communications test"); } void loop(){ if ((((unsigned) millis()) - tStart) > tWait ) { Serial.println("Step # " + String(intSteps)); testRS232_write(intSteps); tStart = (unsigned) millis(); intSteps += 1; if (intSteps == 9) intSteps = 1; testRS232_read(); } }

void testRS232_write(int intSteps){

int intInput = intSteps + 128; int intOutput = intSteps + 128;

byte bFirst = B00000001; byte bSecond = B10000000; byte bThird = B10000000; byte bFourth = B10000001;

bFirst = B00000001; bSecond = byte(intInput); bThird = byte(intOutput); bFourth = B10000001;

Serial1.write(bFirst); Serial1.write(bSecond); Serial1.write(bThird); Serial1.write(bFourth);

Serial1.write("A test message");

} void testRS232_read(){

    Serial.println("Reading...");
    int  serIn; 
    while (Serial2.available()>0){
    serIn = Serial2.read();	        
    Serial.println(serIn, BYTE); 
    } 

}


Ian Billing

Sun, 25 Aug 2013 08:12:10 +0000

Apologies - should have searched the forum more diligently before posting. Fix found at :

http://chipkit.org/forum/viewtopic.php?f=6&t=2481

Thanks


majenko

Sun, 25 Aug 2013 09:59:04 +0000

Yep. I think I was first to spot that bug. The £5 is mine! ;)