Jump to content

josef

EstablishedMember
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

0 Neutral

About josef

  • Rank
    Newbrie
  1. Quick update. asmallri, I'm not using a bootloader. I sent the project to Pavel and he is having a look. --josef
  2. Well, I hit this problem again tonight in two different projects. Things were working fine for a while and then I saw that in any function where I was receiving a string param from a quoted string the memory would consistently be munged (this time first couple of bytes). I decided to call it a night, and then thought to try one more thing and to my surprise it actually worked. I took any call like the following: ser_string_out("Controller v0.1", COM_PC); // FYI: void ser_string_out ( const char * pString, int pCom ); and changed it to read: ser_string_out((char *)"Controller v0.1", COM_PC); And that fixed the problem in both projects (which each had multiple calls in that format). Wish I could explain what causes this problem to start happening, but at least now I know how to prevent it. --josef
  3. Good call. That is more readable. So, you could define something like: #define isset_bit( reg, bitNumb ) reg & (1 << bitNumb) resulting in: if (!isset_bit(portb,S_R)) --josef
  4. I tried building a new project with just the sample code and...it worked fine. Then pulled up the project that was having the problem last night, changed the int back to a char (which consistently caused the problem I was seeing) and...it worked fine. I tried several things to make it repro (I had a suspicion that it involved low available RAM and dynamic var creation) but nothing panned out. Anway, I'll assume it was something I did and let you know if I can find a way to consistently repro it. Thanks for having a look! --josef
  5. Or, if you want to maintain consistency, you could 1) write your own isset_bit() type macro (as mentioned by Yodar), or 2) use the form: if ( portb>>S_R & 0x01 ) Hope that's helpful. --josef
  6. I'm thinking that this may be a real bug so I'm posting here as well... Info: BoostC 1.6 ALPHA, IDE 5.7, Target PIC16F84A I'm seeing a memory overwrite with the following code: char g_vidRAM[21]; void main() { // Do some stuff lcd_print("+------------------+", 1); // Do some more stuff } void lcd_print ( const char * pStr, int pLine ) { vidstrcpy(g_vidRAM,pStr); // Do even more stuff } void vidstrcpy (char * pdest, const char *psrc) { char i_problem = 0; while (psrc[i_problem]!=0x00) { pdest[i_problem] = psrc[i_problem]; i_problem++; } } What I see is that on initialization of i_problem, the psrc string has its last couple of bytes overwritten. BUT if i_problem is changed to an int data type then things work fine. Thanks! josef
  7. SnakeByte, Thanks for the reply. >... but, in mystrcpy you're copying the string and then never appending >the zero terminator to the destination. Yes. Exactly. The mystrcpy function is to copy strings into my LCD "video RAM", it wouldn't do to copy NULLS >Btw, Pavel went through the trouble to provide a strcpy function already, why write >your own? It looks like Pavel has done tons of great work; I'm really enjoying it! Do you have any thoughts on the issue I'm seeing? --josef
  8. This is interesting... If I replace the mystrcpy call with: void mystrcpy (char * pdest, const char *psrc) { int i = 0; while (psrc!=0x00) { pdest = psrc; i++; } } Then things work great. BUT if I change the variable i from type int to type char the overwrite problem comes back. --josef
  9. I'm evaluating SourceBoost (using the BoostC Alpha - 1.6) and so far I love it. Tonight I'm running into a strange problem though. Debugging the following code for a PIC16F84A I see a string being overwritten: char g_vidRAM[21]; void main() { // Do some stuff lcd_print("+------------------+", 1); // Do some more stuff } void lcd_print ( const char * pStr, int pLine ) { mystrcpy(g_vidRAM,pStr); // Do even more stuff } char mystrlen ( const char * string ) { char size; for (size = 0; string!=0; size++); return size; } void mystrcpy (char *pdst, const char *psrc) { int i; char size = mystrlen(psrc); for (i=0; i<size; i++) { pdst = psrc; } } What I see is that after the mystrlen call executes, the psrc string has its last couple of bytes overwritten. It's late, so maybe I'm just missing something obvious...Can anyone tell me if this is a compiler bug (or good old fashioned user error)? Thanks! josef
×
×
  • Create New...