Jump to content

JorgeF

EstablishedMember
  • Content count

    300
  • Joined

  • Last visited

Community Reputation

0 Neutral

About JorgeF

  • Rank
    Super Enthusiast

Profile Information

  • Gender
    Male
  • Location
    ES @ Europe, third rock from the Sun
  1. Hi I missed this topic in due time,so I don't know if this repply is usefull, but here it goes. That is a nice ASM trick, but I think its uneeded in 'C' and also undesired. Its not a good idea to directly manipulate the stack when using a compiled language, because you don't control how the compiler handles the stack. Also bear in mind that due to the limited stack size and specific stack access instructions of the 8 bit PICs, BoostC and other compilers implement a so called "software stack" to handle parameters and automatica variables. The hardware stack is used only for return addresses. To store strings in the program memory you can use the "rom" qualifier (page 47 of the Boost C manual) and then the usual 'C' tools to work with them. HIH Best regards Jorge
  2. Incorrect code generated

    Hi I've confirmed the Bug, both for C and C++. But as I can't solve it, I would suggest 2 alternatives that generate correct code: while(c--) or while(c = c -1) HIH Best regards Jorge
  3. Hi Check the figure 14-3 and 14-4 @ page 136 of the datasheet and cross-reference it with figure 12-1 @ page 126. The TMR2/PR2 match signal that sets the PWM output to 1 also sets the TMR2IF interrupt flag to 1 via the TMR2 post-scaller. HIH Best regards Jorge
  4. Hi I think you are wrong here. The beginning of the PWM cycle happens when TIMER2 is reseted due to a match with PR2. When Timer2 = PR2 a match interrupt is generated (TMR2IF). If you set the Timer2 postscaller to a 1:1 ratio, you will have this interrupt generated at the beginning of every PWM cycle. HIH Best regards Jorge
  5. Hi You already have a timer associated with the PWM signal. Why don't you use it?. The period signal is defined by a timer, things start when yes start the timer. Use the comparator to stop it and read the value. Another thing I'm not sure the PWM is the better tool for the job, because the becessary duty cycle to charge the capacitor is unknown. HIH Best regards Jorge
  6. Hi The same solution works for all libs. Also its valid to the old MPLab 8.xx as for MPLab X. If memory is not tricking me, this is documented in the manuals. Best regards Jorge
  7. To define or not to define

    Hi Ops!! Stealing an header file from a different compiler might yield some surprises. But if you really need to steal one for BoostC, better steal it from XC8 from Microchip. The target devices are the same for XC8 and BoostC (PIC10/12/16/18) so you won't risk any nasty surprise when using multibyte formats (16/24/32 bits). Anyhow, I would check it in detail, probably there are number of conditionals (#ifdef) based on the default symbols defined by the compiler itself. If you find any, adjust it for the "BoostC" equivalent symbols. Best regards Jorge
  8. To define or not to define

    Hi Nothing, the "#ifnedf" can't do a thing there. I guess that somewere along the way they moved the definition of "uint8" from the preprocessor to the compiler but didn't correctly adjust everything. The "#ifndef" is a pre-processor directive that will only detect a symbol defined with "#define" or the equivalent command line parameter. The "typedef" is a 'C' statement to be processed by the compiler. The preprocessor knows nothing about 'C' statements so it just ignores the "typedef". AFAIK the correct way to defined a type is using "typedef", but to be able to protect it against redefinition a "#define" is needed. So in my opinion it should be something like this. #ifndef UINT8_T #define UINT8_T typedef unsigned char uint8 #endif OTOH, the "stdint.h" header has all the standard integer types defined and is globally protected against multiple inclusion, so I see no point on adding this extra type definition anywhere in a project. Some guys just like to re-invent the wheel over and over.... Probably this all thing is just an artifact/bug resulting of a chain of evoluctionary steps of the "float" lib. Best regards Jorge
  9. sprintf incorrect output

    Hi In my previous post I was refering to a generic "C" "sprintf" function. Meanwhile I revised the "BoostC" manual and noticed that the "sprintf" implementation in "BoostC" is a very limited one. I did some testing and it looks like the positive sign is beeing misplaced. OTOH the function is only available for positive numbers (unsigned) so you may either drop the sign or just stuff it at the beginning of the generated string. Something along this lines .... buffer[0] = '+'; sprintf(buffer+1, "%02d", 1); You may need to adjust field lenght or the order of statements for fine tunning your result. HIH EDIT ADD: Besides the testing for this topic, I had never used "sprintf" in BoostC or XC8, simply because I consider it too heavy (code size and speed) for an 8 bit PIC. I allways use the lightweight counterparts and add any needed handcrafted code for the specific formatting on a project by project basis. Best regards Jorge
  10. sprintf incorrect output

    Hi I'm not that sure that the constant value "1" is interpreted as unsigned int. It will most probably be interpreted as (converted to) an "int" as "int" is the default format in "C". Anyhow the "sprintf" function will take anything you throw as a parameter and will "interpret" each parameter acording to the format specifier on the formating string. EDIT: Correction The above aplies to the "printf/sprintf" familly of functions usually found on "C" compilers for desktop or high end microcontrollers, not to the limited implementation available in "BoostC". Sorry for any incovenience. Best regards Jorge
  11. Hi Glad it helped. Best regards Jorge
  12. Hi Did you run "goodies" in "run as administrator" mode? It is trying to write to a folder under "program files(x86)" wich is write protected for any user level but the administrator. HIH Best regards Jorge
  13. NEED HELP

    Hi I don't see any error, just what should be expected when compiling an empty program. BoostC is an optimizing compiler meaning it throws away any unused code. Your "main" function is empty, so there is no generated object code (Assignement.obj), hence the linker can't find it. Put something usefull inside your "main" function and the linker will find an object file to link. HIH Best regards Jorge
  14. Hi There is one thing in your logic that you might want to re-evaluate. I wouldn't trust a compiler to organize the code space in a continuos block, most of the ones I know do spread chuncks of code all over the place just to optimize for the addressing scheme of the PIC (mnimize pagging). The same spreading, for the same reasons, might be found with RAM usage. If you intend to use some part of your flash memory for data you would better reserve it. Use the "-rt" command line switch to limit the maximum address available for the program and use the flash above that address for runtime data (NVM). A work around for your initial question can be to adjust the top of rom (-rt) close the the actual size of your release code and calculate the CRC from "0x0000" up to your "-rt" value. You can calculate the CRC verification from the data on the HEX file as it is a byte image of what will be recorded in the program flash. BTW: Make sure you do program your release code on blank chips so you can use the erased value of the flash in your CRC calculation. Just my 2 cents of it.... Best regards Jorge
  15. Hi I usually find that kind of information on the HEX file used to program the PIC. If you tell us what is your goal, maybe there are other ways, besides finding the last used flash address, to achieve it. Best regards Jorge
×