Jump to content

DTPIC

EstablishedMember
  • Content Count

    32
  • Joined

  • Last visited

Posts posted by DTPIC


  1. Hi Reynard,

    I am using PIC18F (45K22). I cant really send you full source code, as these are commercial designs and "the customer's property". But here are some snippets:

     

    This is the code as I have followed it; I know I'm not infallible, and I did try to say "if I'm right" ...(!)    see what you think of my understanding:

     

    Looking in the asm output, a RAM byte is assigned for the array called "sw_id":

    gbl_sw_id                        EQU    0x000002FC ; bytes:1             // why!?!?!

     

    Then the _startup code does this:

    _startup
        MOVLW 0x00
        MOVLB 0x02
        MOVWF gbl_segmap, 1
        MOVLW 0x01
        MOVWF gbl_sw_id, 1
        MOVLW 0x02
        MOVWF gbl_xfm_id, 1
        MOVLW 0x03
        MOVWF gbl_sw_xform, 1
        MOVLW 0x04
        MOVWF gbl_mastermodename, 1
        MOVLW 0x05
     

    ... where segmap, sw_id, xfm_id, swxform, mastermodename, are all rom char* arrays.

    Isn't this putting an array token number into RAM?

     

    Example: 'C' definition of sw_id array:

    //                  0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5  6
    //                 <-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->
    rom char *sw_id = "CFGDM1MODTD1TU1DM2TU2TD2DSBDSADM3TD3TU3TD4TU4DM4---";

     

     

    A typical use of the array in 'C' would be 

    romstrget(sw_id,start,length,dest_array);         // romstrget is my function which accesses the array at the array position given by "start",

                                                                                     // then copies "length" bytes to "dest_array", terminating in 0x00

    At the asm level, the array is accessed  using:

        MOVLB 0x02
        MOVF gbl_sw_id, W, 1
        MOVLB 0x03
        MOVWF romstrget_00000_arg_romstr, 1
        MOVF main_1_j, W, 1
        MULLW 0x03
        MOVF PRODL, W
        MOVWF romstrget_00000_arg_start, 1
        MOVLW 0x03
        MOVWF romstrget_00000_arg_len, 1
        MOVLW HIGH(gbl_msg_tmp+D'0')
        MOVWF romstrget_00000_arg_str+D'1', 1
        MOVLW LOW(gbl_msg_tmp+D'0')
        MOVWF romstrget_00000_arg_str, 1
        CALL romstrget_00000
     

    Isn't MOVF gbl_sw_id,W,1,  attempting to access the rom array using a RAM based token value?


    I haven't followed the code to the absolute letter \ byte at this point, so you may be able to set me on the right path...!

     

    Thanks for your time....  still think its a great little compiler, and I'm looking forward to Chameleon...


  2. I recently had a problem with arrays held in RAM being corrupted, so I thought i would move them to ROM using rom char *. I found that it was still possible to corrupt the array output! Here's what i think happened...  

    It looks like the compiler assigns a 256 byte ROM area to every rom char array, regardless of actual size. It then assigns a "rom char array number" (1,2,3, etc) to each array for identification: THEN IT STORES THAT NUMBER IN RAM!

    Consequently, if the area of RAM holding the rom char array number is corrupted, then the rom array output is also corrupted (because you are probably looking in the wrong place in ROM).

    As a (licenced!) commercial user, it is sometimes necessary to try to ensure the contents of a lookup table or array at all costs. (Yes, I am the first to agree that I should be preventing the overwrite of RAM!). If the above is a correct observation, then

    1) this assignment of rom char numbers to RAM is not a good idea-it can be corrupted

    2) we seem to be burning 256 bytes of ROM per array regardless of required size, which also does not help in a tight for space application.

    Looking at the assembly output, it would seem reasonable to hard code the rom array base address; this would also make it easier to make the arrays only the length they need to be (and leave more code space available).  

     

    Maybe you can take this into consideration if you are revisiting rom char array handling in Chameleon.

    (...and it would also be good to be able to assign the contents with 0xnn or \xnn - I think others have reported problems here?) 

     

    Thanks for listening!


  3. Only other things I can tell you:

    1) I use the "#if 1.... #endif" and  "#if 0.... #endif"  constructs to include\"comment out" sections of experimental code...

    2) I have used nested #ifs \ #ifdefs sometimes to 3 or more levels...

    3) there may be #if\#ifdef\#endifs existing inside /*...*/ commented out code, or #if \ ifdef \ #endifs commented out using //....

     

    Hope this helps...

     


  4. I have taken a BoostC project which compiles fine and tried to compile using Chameleon - did a "clean all" then "build" - got the response "failed to index input file", with no extra information about the problem...

    What does this message mean? What do I need to look for to fix it?

    Is there a (pdf?) help guide anywhere for Chameleon, or extra info which which would help to debug?


  5. I have a routine like:

    EEPROMwrite(unsigned char addr, unsigned char* str, unsigned char len)

    {

    // print out hex of string of length "len"...

    }

    I call it using hex replacement values in a string, ie using the "\xnn" replacement method:

    EEPROMwrite(,addr, "\xFF\x00\x01",3);     (prints 00 00 01)

    Now, if a "\x" replacement in the string contains FF (or ff) , the hex value read \ printed is 00 ..

    BUT if the value is preceded by another value (which is not 00 or FF), eg,

    EEPROMwrite(,addr, "\01\xFF\x00",3);     (prints 01 FF 00)

    ... it correctly reads \ prints the hex value as FF!

    To be clear, 

    EEPROMwrite(,addr, "\00\xFF\x00",3);     (prints 00 00 00)

    ... does NOT print out FF, as the preceding value is 00..

     

    I have checked the web and this does not seem to be expected behaviour - can you look into it please?


  6. I have a routine like:

    EEPROMwrite(unsigned char addr, unsigned char* str, unsigned char len)

    {

    // print out hex of string of length "len"...

    }

    I call it using hex replacement values in a string, ie using the "\xnn" replecement method:

    EEPROMwrite(,addr, "\xFF\x00\x01",3);

    Now, if a "\x" replacement in the string contains FF (or ff) , the hex value read \ printed is 00 ..

    BUT if the value is preceded by another value (which is not 00 or FF), eg,

    EEPROMwrite(,addr, "\01\xFF\x00",3);

    ... it correctly reads \ prints the hesx value as FF!

    To be clear, 

    EEPROMwrite(,addr, "\00\xFF\x00",3);

    ... does NOT print out FF, as the preceding value is 00..

     

    I have checked the web and this does not seem to be expected behaviour - can you look into it please?


  7. Thanks Reynard, but that was my first thought too!  (I have  been caught before with that one...).

    If I play with the compiler, I can see some CPUs with values which agree with the data sheets, and others which do not - even though the data sheets are all specifying "Flash (bytes)", not "instructions.

    Also, some TDF files agree with the associated data sheets (eg 44K22), while the TDF for 66K22 does not agree - so there is some inconsistency worth checking!

    I have had a situation where the compiler says "all OK, only used just over 50% program memory" while MPLAB wont load the hex file into the CPU properly  because its too big....

    As an example, my current project uses 66K22: the compiler is saying "ROM available 131072 bytes, ROM used 34774 bytes (26.1%)". But if I look at the program area of the hex file in MPLAB, it has a limit of 0xFFFF (65536 bytes) and has code up to 0x87D6 (which is the 34774 bytes specified by the compiler). Clearly not 26% utilisation..... more like  53%.... compiler is wrong....


  8. In SourceBoostC ver 730, I have noticed that some 18Fxx'K'yy CPUs are returning the wrong program memory size in the IDE (it is often 2x correct value). Examples: 66K22, 67K22.

    If I look in the .tdf files for these CPUs, the same "incorrect" values are present as the program memory ranges. The values are 2 x the size shown in the CPU data sheet.

    This leads to the IDE \ compiler stats being incorrect after a compile (eg, "ROM available:",  "used:" and  "free:" figures)

     

     I have checked a "correct" CPU tdf (eg, 44K22) and the size agrees with the data sheet, and is displayed correctly in the IDE...

     

    Am i missing something about the "factor of 2" on these CPUs? Or is this just a plain and simple error?

     

    (It has turned up on other CPUs too - I will list as I come across them again...)

     

    This may be "old news" now that Chameleon is out, but other users may still be working on 730 and it may be that the error has carried over into the new compiler support files....


  9. I am planning a project for a customer targetting PIC 18F67K40.

     

    This CPU doesn't appear to be supported in the current release (7.30). Can you please provide an update to allow me to use this part?

     

    In general, how is BoostC tracking the appearance of new processors? Is anybody producing new support files for them? Either within the Sourceboost company or the community? Is there some other community support site that I should be looking at?

     

    (I have in the past edited the _PIC18Fxxx.TDF, map.txt and other include files, to add a CPU, but its a tricky process - is there a guide published for "how to" add a CPU to the list? Or could you write one? Or should I write one based on what i have done in the past for you to edit?)

     

    Is there a mechanism for users to contribute "mods" they have made for new CPUs, so they can be sent back into the community?

     

    Still using your product after many years (back to early 6.xx) - many thanks for a great little compiler & IDE. Just wish you would do a PIC32MX one...(!)


  10. It would be handy if a large Read-Only data array could be created in ROM space, to be accessed only by using the table pointer instructions. This array would have to be of a type which relaxes the array size limit of 256 bytes (on PIC18).

     

    At the moment, I can achieve this with a 'C' program I have written which reads the data I want in the large array from an 'h' file and appends extra 'S' records to the SourceBoost .hex file output. The PIC programmer then programs the target with code + data array, which can then be read with a table pointer routine.

     

    However, all this is tedious and timewasting, and especially frustrating as the original data for the large table array is in an 'h' file format anyway!

     

     

    Could you perhaps consider this "large Read Only array" as an addition to a future release of Sourceboost C?


  11. Regarding C compiler \ ver 7.30...

     

    are the Flash \ codespace sizes in the 18F86K22, 18F87K22 TDF files correct? They seem twice as large as the data sheet implies....

     

    My compiler was reporting the ROM available 2 x the size the data sheet says- it also caused some problems loading the code when I exceeded the "50%" value, implying that the compiler had got it wrong.

     

    The sizes of the 85K22 and 65K22 <do> agree with the datasheet however...

     

    Please check - if I've got it wrong, my apologies !

     


  12. Hi,

    currently I have a program which uses 2 dimensional arrays to store lists of menu options. These reside in RAM, because Sourceboost wont support 2D rom arrays. (I am using SB 7.30).

     

    I now have to expand my menus and dont have the space for them in RAM - so I must re-work the code to place the data in rom.

     

    I can get around the 2D array problem with a little work - but in checking on my options in the forum, I see that someone mentioned a "single rom page limit" on rom arrays.

     

    Could you explain a little more please? Is this a limit "per "rom array" or on rom arrays, total?

     

    I could do with a more detailed explanation of rom data limits in the compiler, if you have the time... also any comments on what i am trying to do and whether the method is the best approach, etc

     


  13. I am still using BoostC Ver 6.97. I have created a project using 18F44K20, (a 3V3 CPU) but would like to move it to a 44K22 (a 5V CPU). However, 6.97 doesn't support 44K22 in its target list.

     

    Could you please confirm for me:

     

    1) As far as I can tell, the K20 and K22 are functionally equivalent - so can I compile for a K20 and use the code on a K22?

     

    2) If so, I guess this also applies for 45K20/K22, 46K20/22, etc?

     

    3) Finally, from another part of this topic, it seems I could add the K22 variants by creating (copy K20 part and edit?) a .h, and .tdf file and adding an entry to the map.txt file?

     

     

    I will move up to release 7 when time allows! But I must get this job out first....

     

    Many thanks!


  14. Think I may have found the answer...

     

    The problem is indeed duplication of the "volatile char..." definitions for the CPU registers.

     

    1) I copied the PIC16Fxxx.h file from Sourceboost\include to a file in my project directory, (renaming it for safety) and converted all the "volatile char..." definitions to "extern volatile char...".

    2) In the library project, I included the above .h file and the compilers own boostc.h file.

     

    This now works fine - the loader routine is called from its fixed location at the top of memory, does its stuff (including calls to main program routines) and finally jumps to 0x000 to start the new code...

     

    Interestingly, the RAM is unchanged during this load, so you can leave a main program variable set from the loader module (define it as extern...) to indicate that the restart has occurred as a result of a download, etc...

     

     

    I'd still be interested if anyone can find a cleaner way of doing it...

     

     

    There doesnt seem to be much documentation that I could find on the subject of precompiing libraries, even though the feature is there in BoostC - perhaps someone could write a little something to shed some light on this area?


  15. Hi,

    I am interested in creating a boostc library for a serial loader (<not> a classic "bootloader", but more of an "on demand" loader, for a specific customer application).

     

    To get the serial loader routine to locate at a specific fixed address in memory, I have defined a project which links with the -rb xxxx option; as there is no main() function in the project, I guess this has to be compiled as a library... The routine contains asm instructions, for which it seems the compiler must have system.h included, to be able to interpret the asm.

     

    This compiles ok as a library. But when I try to link this into my main project, the linker says

     

    failure

    Error: Duplicate global var: cmcon

    Error: Duplicate global var: eedata

     

    ...etc.

     

    I think the project is seeing 2 copies of system.h (one from the library, one from the main part), both of which call in the _PIC16Fxxx.h header, and this is causing the duplication. But I must have system.h in my library project, or else it doesnt understand the asm instructions...

     

    I have tried including boostc.h into the lib instead of system.h, but this seems to be too generalised, ie, also does not allow the library asm commands to be understood...

     

    There must be a way of compiling a library a) containing asm commands and :rolleyes: without a duplicate system.h - but I havent found it yet!

     

    Any ideas?


  16. Might be able to answer this one myself....(!)

     

    the buffer is passed to the called function as a pointer - so Im probably being given the sizeof the <pointer>, not the buffer, inside the called function...

     

    ...so sizeof() is working ok after all....(!)

     

    Hope this has been of some use to someone doing something similar...

     

    I suppose I will need to pass the buffer length into the called function as another parameter if I really want to use it there... anybody know any other way?


  17. Hi,

    I have a function into which Im passing a pointer to a char buffer; the sizeof() operator indicates different buffer lengths depending on whether it is used inside or outside the called function:

     

     

    void rcv_RS232_msg(char *buffer); // function def for called function...

     

    void myfunc(void) // calling function

    {

    char msgbuf[20]; // char message buffer

     

     

    printf("size of buffer outside function is: %d",sizeof(msgbuf));

     

    rcv_RS232_msg(msgbuf); // call the function, passing buffer in...

    :

    :

    } // end of calling function

     

     

    void rcv_RS232_msg(char *buffer) // the called function

    {

     

    printf("size of buffer inside function is: %d",sizeof(buffer));

     

    }

     

     

    The result of the first printf is 20 (correct)

    The result of the second printf is 2 (?!?)

     

    It appears that the length of the buffer is not reported correctly using sizeof() from inside the called function into which the buffer has been passed......

     

    I dont think this behaviour is intentional - can you verify this behaviour? Is it on the fix list?

     

     

    Thanks!


  18. Think Ive got 2 problems...

     

    First, I thought that the "compile" option was the incremental compile of editied source files....

    Second, I thought that the "Build" option was a complete buld of all source files - seems that <this> is the incremental option, as it generates a new "makefile.gen" when used...

     

    I think the terminology may be different in Microsoft Visual Studio? This may be where my confusion comes from...

     

     

    The "build" option has shown up another problem - it says

     

    Building...

    FATAL: Don't know how to make: D:\Sourceboost\My

    Done

     

    I think its because I have some path names with embedded spaces, (eg "D:\Sourceboost\My Lib Functions...", as above) which require quotes around them - I have looked in the makefile.gen, and the use of quotes around such pathnames seems to be 'unpredictable' - also notice that the file paths and names in project.__c do not have quotes around them....

     

    Should I be declaring the path\filenames in some other way to get around this, or is this an issue? Can I 'fudge' it temporarily by manually editing the project.__c file to include quotes around the paths?

     

    Thanks!


  19. Hi,

    can you tell me if the BoostC 18F compile is "incremental" (ie, only re-compiles changed source files)? It seems to take the same amount of time to compile regardless of what \ how many source files in the project are changed, and the compiler also lists <all> the source files in the project in the output window as it works through them...

     

    I did see a reference to this in a 2004\5 post, suggesting that the incremental feature had been added, but I am not sure if the response was for 16F only...

     

    ( I am using BoostC V6.60...)


  20. Hi,

    no response to this one after 2 weeks....!

     

    Can anybody

     

    a) verify this problem

    :ph34r: tell me if there are any workarounds

    c) tell me if it's likely to be fixed?

     

    I have previously been using the MPLAB assembler,and it has allowed me to initialise items with many ORed terms in this fashion, so I dont think its completely unreasonable to attempt the same in BoostC?

     

    It looks like the part of the preprocessor which deals with defined constants is not being applied to array initialisation... I am guessing that the fix is not so much a "big block of new compiler code", but a re-direction of an existing part of the preprocessor...


  21. Hi Wally,

    thanks for the reminder about arrays being zero-based - we've all forgotten it sometime! But no confusion there - I said that the <size> of the array was 256 bytes, and I expected to be able to access the last byte (ie, array[255]).

     

    Anyway, all this doesn't change the fact that you get 2 different behaviours from the BoostC compiler depending on whether you try to specify a at declaration... :P It seems that you need to declare a rom char* array without to get the 'correct' (expected?) behaviour from the array afterwards...... I just wanted to point it out for anyone making the same mistake, and for the developers to perhaps get a future release of the compiler to throw out such a rom char* .... declaration...

×
×
  • Create New...