Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by csym

  1. Alex, Dave, Possible, it is correct to mark any variable used in both the main routine and and ISR as volatile. If you don't do this, the main code may take a copy of the variable, so when it is changed in the ISR the change is not seen. Using the volatile keyword causes the compiler to always read the original source of the data every time it is referenced. Hum? In my case variables in question are declared and used only in ISR, so main routine does not have access to them (as far as my understanding goes in compiling and allocating memory locations in generated assembler code. Also, I planned my code in a way that there's only one flag bit playing a role of a mutex that gives access to shared memory locations between ISR and main routine. I've used this piece of code for couple of years now for various PICs and I don't think this has anything to do with my original question. What I am thinking now is that this may have something to do assigning constants to these variables. Sounds so Fox Mulder that it makes me wish I had never ever seen a computer at first place. Wouldn't be the first time to see that my code is a piece of junk. I'll let you know if I have figured out anything new. So far, guys, thank you very much for you help!
  2. Hello again, and thank you for your answers. I didn't mention in my earlier posts that I also tried to assigning values to variables, but that was also no help. Viewing assembly code bar also showed that variables are allocated and not optimized out. Turns out that what you Alex suggested helped in my problem. Declaring the variables as volatile shows them in watch window, no matter if they have initial value assignment or not. So now that my problem is gone, I'm still curious to know what causes this kind of behaviour? Thanks!
  3. Ok, now this is getting even more weird. Changed variable declaration to global scope from function scope and now the values seem to update fine in watch window. What the...? However, I'd like to keep my code tidy and have declarations where they ought to be, so any ideas, what am I missing? No variable declarations in interrupt service routine allowed? Thanks...
  4. Hello all. I hope this is not an RTFM issue, but can not quite figure this out... I'm debugging my code, and for reason unknown the watch window shows "error" value for some variables. What makes this even more confusing is that the variables I'd like to watch are all be in scope as they are declared in beginning of the function, like this: static void Timer1_Event_Handler(void) { unsigned char i, button_port, button_bit, isr_ctrl_button_pushed_bit, isr_ctrl_button_released_bit, isr_ctrl_button_msg_sent_bit, isr_ctrl_button_filter_running , msg_button_pushed_bit; I set a breakpoint in Timer1_Event_Handler function, and some of the variables show up fine, some with value "error". How come? My project has originally been started as wizard generated for PIC 16F877A. After a while I had to add linker option "-swcs 6 2" as size of the code grew up. Could software stack have anything to do with this? Help is really appreciated! TIA
  • Create New...