Pro Micro conflict with timers and serial.print
i trying own version of luc small's weather station decoder working on chinese arduino micro pro (5v). have working fine on uno r3. have adapted code micro pro, changing ports, , have working sort of. works in picking weather station transmissions , decoding them, problem have printing serial monitor, prints first 63 characters each transmission , cuts off mid word.
{"petes_weather_station_status":"started"}
{"sensor_id":"a4e", "humidity":82, "temperature":10.9, "wind_sp
a normal transmission this:
{"sensor_id":"a4e", "humidity":83, "temperature":11.0, "wind_speed":0.0, "wind_speed_max":0.0, "wind_dir":0.0, "rain_sum":506.4, "validity":1, "full_message":"a4 e1 fe 53 0 0 6 98 0 c8 "}↵
it keeps receiving packages, , keeps printing first 63 characters of each serial transmission.
my full code here: https://www.dropbox.com/s/aeblbo71r95bio5/betterwh2_pg_v20_promicro.ino?dl=0
i have tried whole heap of troubleshooting, , believe have narrowed problem down sort of conflict between timer , serial output. code below simple test of timer set , try print text serial monitor. "serial started" text comes through, the pro micro freezes , onboard leds turn on solid.
if comment out timsk1 |= (1 << ocie1a); line, code works fine, , text comes through on serial monitor expected.
can shed light on why wouldn't work?
#define counter_rate 1600
void setup() {
serial.begin(9600);
while (!serial) ; // while serial stream not open, nothing:
serial.println("serial started");
nointerrupts(); // disable interrupts
tccr1a = 0;
tccr1b = 0;
tccr1c = 0;
tcnt1 = 0;
ocr1a = counter_rate; // compare match register
tccr1b |= (1 << wgm12); // ctc mode
tccr1b |= (1 << cs10); // 256 prescaler
timsk1 |= (1 << ocie1a); // enable timer compare interrupt0
interrupts(); // enable interrupts
}
void loop() {
serial.print("i want print text out serial monitor");
delay(10000);
}
{"petes_weather_station_status":"started"}
{"sensor_id":"a4e", "humidity":82, "temperature":10.9, "wind_sp
a normal transmission this:
{"sensor_id":"a4e", "humidity":83, "temperature":11.0, "wind_speed":0.0, "wind_speed_max":0.0, "wind_dir":0.0, "rain_sum":506.4, "validity":1, "full_message":"a4 e1 fe 53 0 0 6 98 0 c8 "}↵
it keeps receiving packages, , keeps printing first 63 characters of each serial transmission.
my full code here: https://www.dropbox.com/s/aeblbo71r95bio5/betterwh2_pg_v20_promicro.ino?dl=0
i have tried whole heap of troubleshooting, , believe have narrowed problem down sort of conflict between timer , serial output. code below simple test of timer set , try print text serial monitor. "serial started" text comes through, the pro micro freezes , onboard leds turn on solid.
if comment out timsk1 |= (1 << ocie1a); line, code works fine, , text comes through on serial monitor expected.
can shed light on why wouldn't work?
#define counter_rate 1600
void setup() {
serial.begin(9600);
while (!serial) ; // while serial stream not open, nothing:
serial.println("serial started");
nointerrupts(); // disable interrupts
tccr1a = 0;
tccr1b = 0;
tccr1c = 0;
tcnt1 = 0;
ocr1a = counter_rate; // compare match register
tccr1b |= (1 << wgm12); // ctc mode
tccr1b |= (1 << cs10); // 256 prescaler
timsk1 |= (1 << ocie1a); // enable timer compare interrupt0
interrupts(); // enable interrupts
}
void loop() {
serial.print("i want print text out serial monitor");
delay(10000);
}
when try follow link, get:
quote
the proxy server refusing connectionsnow, know problem on end (my company's proxy server 1 refusing connection). but, if followed rules, , attached code here, see it.
Arduino Forum > Using Arduino > Programming Questions > Pro Micro conflict with timers and serial.print
arduino
Comments
Post a Comment