Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

timer crash on enable

Status
Not open for further replies.

Dr_Doggy

Well-Known Member
so a bit of history is that i use to not bother with strings cos i knew they were somehow bad, but for this project i had a logbuffer that could sometimes get extremely long and decided to string it.. but after about 12 hrs the fragmens caught up and crashed the atmega2560

so i ran this code to see if i could look in to the mem banks ... there was alot of blocks like this in it.....
Code:
char *p =0;
while (1){Serial.print(p++);}

dogg-house
ogg-house
gg-house
g-house
-house
house
ouse
use
se
e
superyumyum
uperyumyum
peryumyum
eryumyum
ryumyum
yumyum
umyum
myum
yum
um
m
Question #1!! ) is the above result the fragment problem they are talking about or is that my improper use of using a pointer!!?

so i decided to send the strings all to char arrays... conversions went smooth but i made one mistake where i used the ltoa functions very improperly.. but i got all the bugs sorted and this is where i noticed a bigger problem.

so i have been rolling back my code and had to bring it down to this... my problem is that TIMSK3 instructions is locking up arduino, it never makes it to the breakpoint = 1, it never calls the interrupt anymore, and never even makes it to main loop. when i comment that one line out i am able to make it to main loop.
I started off with timer1 and also everything was working before I started messing with the char arrays

could i have messed up a mem block? wouldnt a new upload fix that (also i tried burning new bootloader)?
could this be a HW issue that just so happened when i started messing with pointers?
... something else??:
Code:
#include <Arduino.h>

ISR(TIMER3_OVF_vect)
{
    int xxx = 1;
}

void setupTimer1()
{

    TCCR3B |= (1 << CS10);    // set up timer with prescaler 
    TCCR3B |= (1 << CS11);    // set up timer with prescaler
    TCNT3 = 0;    // initialize counter
    TIFR3 = 0;

    int breakpoint = 0;
    TIMSK3 |= (1 << TOIE3);    // enable overflow interrupt
    breakpoint = 1;
    sei();    // enable global interrupts
    breakpoint = 2;
}

void setup()
{
    setupTimer1();
}

void loop()
{
    while (1)
    {   
        int xxx = 1;
    }
}
 
yes the code above is all actually timer 3 ... it was all timer 1 at the begining ... the setuptimer1 call is just to call the setup vectors (which are for timer3!)

ALSO.. idk that was my first pointer! hope that wasnt self destruct!! .... it seemed to work though as it was dumping stuff!
i have removed that since then ... could that do long term damage?
 
Last edited:
What are you trying to do? In my experience you shouldn't access the hardware direct on the Arduino as the operating system (said loosely) uses most of it. If you need a timed interrupt then look at using Ticker.h.

The serial print of the pointer will print everything up to a carriage return. So your memory contains
dogg-house<cr>superyumyum<cr> etc.

I avoid using the string class as it's reported as having memory leaks. I've always managed with simple C strings.

Mike.
 
Last edited:
I am trying to get the timer function working again... the strange thing is that code above worked till I started messing around with the char arrays... now iv deleted everything but timer still is no go
thanks will try ticker tomorow!
 
I've just realized that the Ticker I'm using is specific to the ESP processors. There does however seem to be similar for UNO etc. but doesn't appear to be interrupt driven.

Mike.
 
Here's a simple example that works on ESP boards.
Code:
#include <Ticker.h>
Ticker IRQ;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  IRQ.attach_ms(500,ISR);
}

void ISR(void){
  digitalWrite(LED_BUILTIN,!digitalRead(LED_BUILTIN));
}

void loop(){
}

It flashes the on board LED at 1Hz. As you can see it's very simple.

Mike.
 
Breakpoint.... Breakpoint - on an Arduino. Time to do some research.

Mike.
 
oh..ya.. i use the visual micro plugin for visual studio, cuts down on the compilers i need ... . not really a true breakpoint but an interesting way to implement a virtual one...
 
Does that plugin work with the free version of VS?

Googling suggests that on the ESP you can have real breakpoints. I like these chips - 80k ram 4M flash and 80MHz speed and about $4 each.

Mike.
 
i got vs pro 2013 .. not sure if mines free or not, but it should work
check it out!:
https://www.visualmicro.com/

also do you got a link for the ESP , i wouldnt mind checking it out .. i like the mega2560 cos it has lots of headers and for this project i have them half filled up already but only 10%program memory full
20180924_225828.jpg
 
wait .. im confused i have a ESP8266 serial wifi module sitting in front of me i thought it was just a wifi module are you saying that i can program it without destroying the wifi stack?? or maybe mine is different from that?

also since were on the topic.. are you able to send outgoing requests with it? ... that is one thing i was never able to get working on the mt7681
 
The Wemos and Lolin boards have 4M of flash on board and a USB to RS232 converter. **broken link removed**. I'm assuming the flash is used to hold the external program.

I currently have a wemos mini board setup as a server. It is configured with a 3M spiffs drive and 1M program space. This can act as an access point, connect to wifi, serve up html pages, read a DHT22. The html pages can use GET and POST to read/store files and fetch the DHT data. The 1M program space is about half full.

I have a second wemos board driving a 32x8 LED display using MAX7219s and that connects to my wifi, fetches the IP address of time servers and then gets the time. Is this what you meant by outgoing requests?

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top