Jump to content

bongo

EstablishedMember
  • Content Count

    34
  • Joined

  • Last visited

Community Reputation

0 Neutral

About bongo

  • Rank
    Regular
  1. i really tried to be nice ;-) i already tried different ways to tell the compiler about array size...and all i get is an "error: missing right paren". that's all ;-( using global access is no way to go, as i have multiples of these arrays, but all of them have to be processed using the same functions. the only way i see so far is to convert to a 1D array and calculate position myself, although i think that ansi c should support 2D arrays in functions. thanx!
  2. hi it's a 18f2525. with a bank size of 256 bytes, i think this shouldn't be a problem. regards bongo
  3. i try to include a 2 dimensional arrays in function calls to have functions doing some modifications to arrays. a very simple example to initialize the array is: unsigned char MATRIX[15][16]; void Init (unsigned char *myMATRIX) { unsigned char x,y; for (x=0;x<15;x++) { for (y=0;y<16;y++) { myMATRIX[x][y] = x+y; } } } void main (void) { Init(MATRIX); } i would expect that a memory area of 240 bytes would be reserved for the array variable MATRIX, and when calling the Init function, the start address of this memory range would be given to the Init function. then, the whole MATRIX would be initialized. fact is (same behaviour in simulator and on targed) that bytes from address 0x100 are written up to address 0x10f. then, instead of proceeding with address 0x110, it again writes to addresses 0x100 to 0x10f. addresses above 0x10f are never written. what am i doing wrong? i think my syntax isn't too bad ;-( thanx for your help!
  4. When using BoostC from within the Sourceboost IDE, it does a smart build, i.e. only the files that have changed are recompiled. for all other files, the existing object files are used. When using MPLAB (as an ide for BoostC) to build the design (i think i have to, if i want to debug using ICD2), then on each build, all files are compiled again, no matter if they have changed or not. So this is the most time consuming part of the process when fixing little bugs, as it compiles only on 1 core of a quad core cpu. Is there a way to configure MPLAB to only recompile the files that have changed? thanx!
  5. that's how i finally did it, after giving up the initial concept... thanx! bongo
  6. to make it a bit more clear, here the test proggy: #include <system.h> #include "SndSer18a1.h" void main (void) { unsigned char myarray[15][6]; PrintMyArray(myarray); } void PrintMyArray(unsigned char *thearray) { for (unsigned char i=0; i<6;i++) { SsTxt(thearray[i]); } } void SsTxt(const unsigned char *text) { unsigned char loop; loop = 0; while ((text[loop] !=0) && (loop < 255)) { SsSend(text[loop++]); } } i get an error message for the line SsTxt(thearray); which tries to give a single line of text to the SsTxt function. when i modify to SsTxt(thearray); i get no more error, but this will for sure access the whole array instead of only a line. how do i have to modify to access single lines of text in my array? thanx!
  7. i have a multidimensional array, or let's say an array of string, that i would like to use in a function. i tried ma make an exemple: unsigned char myarray[15][6]; these are 6 strings of the lenght of 15 characters. right? now i want to give this to a function by reference: PrintMyArray(myarray); the function itself is defined as: void PrintMyArray(unsigned char *thearray) { for (unsigned char i=0; i<6;i++) { printF(thearray[i]; } } unfortunately, this does not work. what do i have to do to give an array to function? thanx!
  8. hi dave thanx for the answer! looks like i found the reason: when optimization is enabled in mplab, it compiles and links with the -O1 option, resulting in the bigger code. when i turn off optimization, there is no such option and the result shrinks to 92%. this behaviour does not really make sense, but at least it seems to work now! thank you! regards bongo
  9. when i build my project within the sourceboost IDE (6.96), it requires for 92% program memory. when i build from within MPLAB 8.40, after a very looooong time i get a failure and it reports that the design requiers for 101% program memory. i already had this effect with former projects, requiring for about 10% more program memory when building them from within MPLAB. what am i doing wrong? thanx!
  10. i usually put functions that i use for several projects into libraries instead of adding the c-code to each project. now i have some functions that have to behave different, depending on the pic i use, i.e. there are some lines that are different for slow or fast processors. i used to have a #ifdef slowpic <code for slow version> #else <code for fast version> #endif construct in my source code, while having a #define slowpic in the globaldefs.h file when using a slow processor. now i think about moving the whole stuff into a .lib file. is it possible to still have this construct inside the c source, or how can is solve this to still have the possibility to switch between a slow and a fast version? thanx for your help!
  11. looks like eeprom simulation does not work. for details, refer to detailed description (within this forum)
  12. looks like this is really a simulator bug!! running the procedure on a real target works!
  13. i also tried the built-in eeprom access tasks. looks like they also do not work on the simulator. what am i doing wrong???
  14. i try to use the sourceboost simulator to check if my code for accessing internal eeprom of a 18f2525 works. my code is a 1:1 asm2c conversion of the microchip example code. result: - my code does not work (on the simulator, didn't test on a target yet) - the simulator shows strange behaviour SIMULATOR PROBLEMS: i first write a few bytes of data to the eeprom window of the simulator (manual entry). this looks ok, but as soon as i start simulation (first step into the program, with no access to the eeprom), each even address of the eeprom gets overwritten with the data from the next higher odd byte. this looks really strange to me. didn't i understand the eeprom simulation model, am i completely nuts or is there really a bug in the simulator? MY CODE: i wrote an eeprom driver to read/write 8bit and 16bit values from/to the eeprom. although this accesses the eeprom registers of the sourceboost simulator, the data i write is not written to the eeprom window (of the simulator), and when reading, the value of eedata does not get changed. what am i doing wrong? below, you find my code... thank you very much for your help!!! C CODE: /* internal eeprom access for pic18 r0.01 initial */ #include <system.h> #include "P18INTEEAr0_01.h" unsigned char P18IntEeWrite8 (unsigned int addr /*eeprom address*/, unsigned char data /*data to be written*/) { //writes 8 bit data to address //returns 0 if ok clear_bit(pir2,EEIF); //clear end of eeprom write HIBYTE(eeadrh,addr); //Upper bits of Data Memory Address to write LOBYTE(eeadr,addr); //Lower bits of Data Memory Address to write eedata = data; //Data Memory Value to write clear_bit(eecon1, 7); //Point to DATA memory clear_bit(eecon1, CFGS); //Access EEPROM set_bit(eecon1, WREN); //Enable writes clear_bit(intcon, GIE); //Disable Interrupts eecon2 = 0x55; //requred Write 55h eecon2 = 0xaa; //requred Write 0AAh set_bit(eecon1, WR); //Set WR bit to begin write set_bit(intcon, GIE); //Enable Interrupts for (unsigned char i = 0; i<200; i++) { if (test_bit(pir2,EEIF)) i = 200; delay_ms(1); } clear_bit(eecon1, WREN); //Disable writes on write complete (EEIF set) clear_bit(pir2,EEIF); //clear end of eeprom write if (P18IntEeRead8(addr) == data) return 0; else return 1; } unsigned char P18IntEeWrite16 (unsigned int addr /*eeprom address*/, unsigned int data /*data to be written*/) { //writes 16 bit data to address (upper byte) and address+1 (lower byte) //returns 0 if ok unsigned char tmp, tmp2; HIBYTE(tmp,data); //access upper byte tmp2=P18IntEeWrite8(addr,tmp); LOBYTE(tmp, data); //access lower byte tmp2=tmp2 || P18IntEeWrite8(addr+1,tmp); return tmp2; } unsigned char P18IntEeRead8 (unsigned int addr /*eeprom address*/) { //reads 8 bit data from address //returns data unsigned char tmp; eedata = ~eedata; //invert to see if value changes on read (in the simulator) HIBYTE(eeadrh,addr); //Upper bits of Data Memory Address to read LOBYTE(eeadr,addr); //Lower bits of Data Memory Address to read clear_bit(eecon1, 7); //Point to DATA memory clear_bit(eecon1, CFGS); //Access EEPROM set_bit(eecon1, RD); //EEPROM Read return eedata; } unsigned int P18IntEeRead16 (unsigned int addr /*eeprom address*/) { //reads 16 bit data from address (upper byte) and address+1 (lower byte) //returns data unsigned int tmp; tmp = P18IntEeRead8(addr) * 0x0100; tmp = tmp + P18IntEeRead8(addr+1); return tmp; } AND WHAT THE COMPILER GENERATES OUT OF IT (only the 8 bit procedures): unsigned char P18IntEeWrite8 (unsigned int addr /*eeprom address*/, unsigned char data /*data to be written*/) { //writes 8 bit data to address //returns 0 if ok clear_bit(pir2,EEIF); //clear end of eeprom write 1A4A 98A1 BCF gbl_pir2,4 HIBYTE(eeadrh,addr); //Upper bits of Data Memory Address to write 1A4C 0101 MOVLB 0x01 1A4E 5101 MOVF P18IntEeWr_00056_arg_addr+D'1', W, 1 1A50 6EAA MOVWF gbl_eeadrh LOBYTE(eeadr,addr); //Lower bits of Data Memory Address to write 1A52 5100 MOVF P18IntEeWr_00056_arg_addr, W, 1 1A54 6EA9 MOVWF gbl_eeadr eedata = data; //Data Memory Value to write 1A56 0100 MOVLB 0x00 1A58 51FF MOVF P18IntEeWr_00056_arg_data, W, 1 1A5A 6EA8 MOVWF gbl_eedata clear_bit(eecon1, 7); //Point to DATA memory 1A5C 9EA6 BCF gbl_eecon1,7 clear_bit(eecon1, CFGS); //Access EEPROM 1A5E 9CA6 BCF gbl_eecon1,6 set_bit(eecon1, WREN); //Enable writes 1A60 84A6 BSF gbl_eecon1,2 clear_bit(intcon, GIE); //Disable Interrupts 1A62 9EF2 BCF gbl_intcon,7 eecon2 = 0x55; //requred Write 55h 1A64 0E55 MOVLW 0x55 1A66 6EA7 MOVWF gbl_eecon2 eecon2 = 0xaa; //requred Write 0AAh 1A68 0EAA MOVLW 0xAA 1A6A 6EA7 MOVWF gbl_eecon2 set_bit(eecon1, WR); //Set WR bit to begin write 1A6C 82A6 BSF gbl_eecon1,1 set_bit(intcon, GIE); //Enable Interrupts 1A6E 8EF2 BSF gbl_intcon,7 for (unsigned char i = 0; i<200; i++) { 1A70 0101 MOVLB 0x01 1A72 6B02 CLRF P18IntEeWr_00056_1_i, 1 1A74 label157 1A74 0EC8 MOVLW 0xC8 1A76 6102 CPFSLT P18IntEeWr_00056_1_i, 1 1A78 D00A BRA label159 1A8A 2B02 INCF P18IntEeWr_00056_1_i, F, 1 1A8C D7F3 BRA label157 1A8E label159 if (test_bit(pir2,EEIF)) i = 200; 1A7A A8A1 BTFSS gbl_pir2,4 1A7C D002 BRA label158 1A7E 0EC8 MOVLW 0xC8 1A80 6F02 MOVWF P18IntEeWr_00056_1_i, 1 1A82 label158 delay_ms(1); 1A82 0E01 MOVLW 0x01 1A84 6F0E MOVWF delay_ms_00000_arg_del, 1 1A86 EC10F000 CALL delay_ms_00000 } clear_bit(eecon1, WREN); //Disable writes on write complete (EEIF set) 1A8E 94A6 BCF gbl_eecon1,2 clear_bit(pir2,EEIF); //clear end of eeprom write 1A90 98A1 BCF gbl_pir2,4 if (P18IntEeRead8(addr) == data) 1A92 5100 MOVF P18IntEeWr_00056_arg_addr, W, 1 1A94 6F0B MOVWF P18IntEeRe_00058_arg_addr, 1 1A96 5101 MOVF P18IntEeWr_00056_arg_addr+D'1', W, 1 1A98 6F0C MOVWF P18IntEeRe_00058_arg_addr+D'1', 1 1A9A EC93F004 CALL P18IntEeRe_00058 1A9E 0100 MOVLB 0x00 1AA0 51FF MOVF P18IntEeWr_00056_arg_data, W, 1 1AA2 0101 MOVLB 0x01 1AA4 630D CPFSEQ CompTempVarRet1367, 1 1AA6 D002 BRA label160 1AAC label160 return 0; 1AA8 6B03 CLRF CompTempVarRet1366, 1 else return 1; 1AAC 0E01 MOVLW 0x01 1AAE 6F03 MOVWF CompTempVarRet1366, 1 } 1AAA 0012 RETURN 1AB0 0012 RETURN unsigned char P18IntEeRead8 (unsigned int addr /*eeprom address*/) { //reads 8 bit data from address //returns data unsigned char tmp; eedata = ~eedata; //invert to see if value changes on read (in the simulator) 0926 1CA8 COMF gbl_eedata, W 0928 6EA8 MOVWF gbl_eedata HIBYTE(eeadrh,addr); //Upper bits of Data Memory Address to read 092A 510C MOVF P18IntEeRe_00058_arg_addr+D'1', W, 1 092C 6EAA MOVWF gbl_eeadrh LOBYTE(eeadr,addr); //Lower bits of Data Memory Address to read 092E 510B MOVF P18IntEeRe_00058_arg_addr, W, 1 0930 6EA9 MOVWF gbl_eeadr clear_bit(eecon1, 7); //Point to DATA memory 0932 9EA6 BCF gbl_eecon1,7 clear_bit(eecon1, CFGS); //Access EEPROM 0934 9CA6 BCF gbl_eecon1,6 set_bit(eecon1, RD); //EEPROM Read 0936 80A6 BSF gbl_eecon1,0 return eedata; 0938 50A8 MOVF gbl_eedata, W 093A 6F0D MOVWF CompTempVarRet1367, 1 } 093C 0012 RETURN
  15. hi pavel i have 6.93rc2 What compiler version do you use? Version 6.92 is broken in this respect (projects that have sources not in the project dir may not build). All other releases are fine (including 6.93 RC).. Pavel
×
×
  • Create New...