Arduino is locked

The purpose of the next program is to periodically output data to the serial port. The period is determined by a temporary interruption every second.

The code worked on the Arduino 0022 IDE version, but in 1.0 I can't get it to work. When using the timer procedure and maxFrameLengthset to 0x40or higher, the controller locks. When using 0x39 or lower, the program continues to run (indicated by a flashing LED).

What is going on here and why? This is mistake? Am I doing something wrong?

I am using http://code.google.com/p/arduino-timerone/downloads/detail?name=TimerOne-v9.zip for the timer procedure on the Mega1280.

#include "TimerOne.h"

#define LED 13
#define maxFrameLength 0x40

boolean stateLED = true;
byte frame[ maxFrameLength ];

void sendFrame() {
  digitalWrite( LED , stateLED );
  stateLED = !stateLED;
  Serial.write( frame, maxFrameLength ); // ptr + bytes to send
}

void setup() {
  pinMode( LED , OUTPUT );
  Timer1.initialize( 1000000 );  // initialize timer1 with 1 second period
  Timer1.attachInterrupt( sendFrame );
  Serial.begin( 9600 );
};

void loop() {
};
+3
source share
2 answers

, , . ; Arduino .

Serial.write() (ISR). Serial , . , , , . , , , Serial.write() . 0x40 (64 ) , , , . , , ISR.

, , , , , , , 9600, n, 8,1, 64 67 , .

stateLED frame ( ) volatile.

, frame , , frame - 1.


A.H. . Serial - HardwareSerial, \arduino-1.0\hardware\arduino\cores\arduino\hardwareSerial.cpp/.h. 64 , HardwareSerial::write() "-", . write().

, , - , 1.

+7

1.0 :

  • , Serial.print() .. , . , Serial.flush() , .

1.0, HardwareSerial::write(uint8_t) ( ) .

, Serial .

+6

All Articles