Go Down

Topic: DuinOS: small and simple rtos (Read 51 times) previous topic - next topic

gwen

#40
Nov 21, 2009, 11:35 pm Last Edit: Nov 21, 2009, 11:40 pm by gwen Reason: 1
nope used serial output in my tasks instead of leds and worked perfectly in tasks and loop and works in setup just one wire is issue..

    gwen

juliandasilva

Well, I'm here again. Thanks guys! I have tested the ASCCITable example with DuinOS in the m328 (Seeeduino v328) and with the m1280 (Seeeduino Mega). The setup routine seems to be similar to that described by Chumbud:

Code: [Select]
void setup()
{
 Serial.begin(9600);

 // prints title with ending line break
 Serial.println("ASCII Table ~ Character Map");
}


and it works fine.
More, the loop routine is this, and works too:

Code: [Select]
void loop()
{
 // prints value unaltered, i.e. the raw binary version of the
 // byte. The serial monitor interprets all bytes as
 // ASCII, so 33, the first number,  will show up as '!'
 Serial.print(thisByte, BYTE);    

 Serial.print(", dec: ");
 // prints value as string as an ASCII-encoded decimal (base 10).
 // Decimal is the  default format for Serial.print() and Serial.println(),
 // so no modifier is needed:
 Serial.print(thisByte);      
 // But you can declare the modifier for decimal if you want to.
 //this also works if you uncomment it:

 // Serial.print(thisByte, DEC);  


 Serial.print(", hex: ");
 // prints value as string in hexadecimal (base 16):
 Serial.print(thisByte, HEX);    

 Serial.print(", oct: ");
 // prints value as string in octal (base 8);
 Serial.print(thisByte, OCT);    

 Serial.print(", bin: ");
 // prints value as string in binary (base 2)
 // also prints ending line break:
 Serial.println(thisByte, BIN);  

 // if printed last visible character '~' or 126, stop:
 if(thisByte == 126) {     // you could also use if (thisByte == '~') {
   // This loop loops forever and does nothing
   while(true) {
     continue;
   }
 }
 // go on to the next character
 thisByte++;  
}


Chumbud: could you please upload the complete code, and any other info that may help us to see where is the problem?

Thanks, and regards,
Julián
http://robotgroup.com.ar

Chumbud

#42
Nov 22, 2009, 05:21 am Last Edit: Nov 22, 2009, 05:22 am by chumbud Reason: 1
Tracked the problem to using an ATmega168 + DuinOS.  Doing ATmega328 + DuinOS (of course switching to an actual 328 chip) printed the text from serial.  Using normal non-DuinOS ATmega168 also printed out the text.  Used your above sample code to test.

gwen

the problem being is a lot of delay and delaymicrosecond calls in onewire protocols  software support, i2c is mostly hardware support on the other hand and seems to be working fine(at least to the RTC1307 I2c interface)

   gwen

juliandasilva

#44
Nov 22, 2009, 05:51 am Last Edit: Nov 22, 2009, 05:17 pm by juliandasilva Reason: 1
Thanks. I haven't got the 168 hardware right now, but I think it may be a RAM issue. I will try to do some tests this week (but it's a hard week :) ).
But looking at the HardwareSerial.h and HardwareSerial.cpp files, I saw that we forgot to create the instances for the Serial1 when the 644 and the 1284 CPUs are used. It will be done in the v0.2 version, but now you can add something like this to your files:

HardwareSerial.cpp:

Code: [Select]

#if defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1);
#endif



HardwareSerial.h:

Code: [Select]

#if defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
extern HardwareSerial Serial1;
#endif


Regards,
Julián
http://robotgroup.com.ar

Go Up