Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by TomF

  1. if i remove the inline keyword, i get function redefinition error 'apple', so i move the body of apple() to .c, and it works fine, meaning apple can access __apple from a different file. So, your explainaton is either wrong, or i've missunderstood.
  2. Hi, Using inline: -- file1.c -- static char __apple(char a, char b) { return a + b; } -- file1.h -- // private function, cant be accessed from main. static char __apple(char a, char b); // access function. inline char apple(char a) { return __apple(a, 10); } -- main.c -- #include "file1.h" char x = apple(123); // error = unresolved external '__apple' Why is __apple unresolved? its clearly exists (in the .c and .h file), and is defined and used correctly. If i move __apple function body to the .h file, it works fine. Is this a bug? Remove the inline keyword and it works, however, the compiler calls apple, which then calls __apple. Why cant the compiler simply optamise out the extra call and just call __apple ??
  3. Do you know when pre will be out? a week, a month? a year?
  4. Any idea when V7 will be released? Its just too close (V6.97) to buy a licence without free guaranteed upgrade. I'll never convince them its a good idea, which is a shame as i cant stand the hitech compiler!
  5. Hi, My clock is 8MHz. This routine takes 204us to complete as measured on a scope. I cant seem to figure it out, i thought each instruction in a pic took 4/clock = 0.5us to execute? char nUS; for(;;) { nUS = 100; toggle_bit(PORT_SERIAL_DEBUG, PIN_SERIAL_DEBUG); asm { Loop: nop decfsz _nUS, F goto Loop } } as the asm has 3 instructions, each 0.5us, how can this take 200us?
  6. Hi, The company im working for will soon need a boostc licence becuase im planning on using it for a project here (use it at home so non-comercial stuff). They will NOT buy a licence at the moment becuase your on version 6.97 and version 7 is due any time. This is a real PITA because im writing code using hi-tech which i hate until i can get them to buy a licence. What is your policy on free upgrades to v7.x for people that buy a 6.97 licence?
  7. Hi, I have 2 ways of changing the clock freq in the 16F690. Method 1: read / modify / write the osccon reg. Method 2: Over-write the osccon reg with a new value. the generated code is a bit wacky for method 2. Can someone explain? Seems excessive. #define SW_OSCCON_CLOCK_MASK (0x7 << IRCF0) enum INT_CLOCK_FREQS { SW_OSCCON_CLOCK_32KHZ = 0x0, SW_OSCCON_CLOCK_125KHZ = 0x1, SW_OSCCON_CLOCK_250KHZ = 0x2, SW_OSCCON_CLOCK_500MHZ = 0x3, SW_OSCCON_CLOCK_1MHZ = 0x4, SW_OSCCON_CLOCK_2MHZ = 0x5, SW_OSCCON_CLOCK_4MHZ = 0x6, SW_OSCCON_CLOCK_8MHZ = 0x7 }; void ChangeInternalClockFreq(enum INT_CLOCK_FREQS eFreq) { // // Change the internal clock freq. // // Read/modify/write: unsigned char __osccon = osccon; // Read current osccon register. __osccon &= (~SW_OSCCON_CLOCK_MASK); // Clear all osc bits. osccon = __osccon | (eFreq << IRCF0); // Set required freq, and write. // As no other bits are used in the osccon reg, simply overwrite. osccon = 0x00 | (eFreq << IRCF0) // select freq. | (1 << SCS) // Use software selectable osc. ; } void ChangeInternalClockFreq(enum INT_CLOCK_FREQS eFreq) { // // Change the internal clock freq. // // Read/modify/write: unsigned char __osccon = osccon; // Read current osccon register. 0191 1683 BSF STATUS, RP0 0192 080F MOVF gbl_osccon, W 0193 1283 BCF STATUS, RP0 0194 00A6 MOVWF ChangeInte_00024_1___osccon __osccon &= (~SW_OSCCON_CLOCK_MASK); // Clear all osc bits. 0195 308F MOVLW 0x8F 0196 05A6 ANDWF ChangeInte_00024_1___osccon, F osccon = __osccon | (eFreq << IRCF0); // Set required freq, and write. 0197 0E25 SWAPF ChangeInte_00024_arg_eFreq, W 0198 39F0 ANDLW 0xF0 0199 0426 IORWF ChangeInte_00024_1___osccon, W 019A 1683 BSF STATUS, RP0 019B 008F MOVWF gbl_osccon // As no other bits are used in the osccon reg, simply overwrite. osccon = 0x00 01AE 1683 BSF STATUS, RP0 01AF 008F MOVWF gbl_osccon | (eFreq << IRCF0) // select freq. 019C 1283 BCF STATUS, RP0 019D 0825 MOVF ChangeInte_00024_arg_eFreq, W 019E 00A7 MOVWF CompTempVar634 019F 01A8 CLRF CompTempVar635 01A0 0DA7 RLF CompTempVar634, F 01A1 0DA8 RLF CompTempVar635, F 01A2 0DA7 RLF CompTempVar634, F 01A3 0DA8 RLF CompTempVar635, F 01A4 0DA7 RLF CompTempVar634, F 01A5 0DA8 RLF CompTempVar635, F 01A6 0DA7 RLF CompTempVar634, F 01A7 0DA8 RLF CompTempVar635, F 01A8 30F0 MOVLW 0xF0 01A9 0527 ANDWF CompTempVar634, W 01AA 3800 IORLW 0x00 01AB 00A9 MOVWF CompTempVar636 | (1 << SCS) // Use software selectable osc. 01AC 3001 MOVLW 0x01 01AD 0429 IORWF CompTempVar636, W ; } 01B8 0008 RETURN
  8. Ah yes i see. I still prefer the add rather than the OR, seems to make more sense for the dumber programmers (me!)
  9. Should Font[(x<<3)|y] actually be Font[(x<<3) + y] since its character (x<<3) plus offset into character (+y) ?
  10. Hi, Does the simulator now work with 12F targets? I need to simulate some code - its a count-down timer so i need leds and switches. Press a switch, an led will light. 3 mins and 30 secs later, the led will go out. I have to confirm that it goes out after this time (will be using my wrist watch).
  11. TomF

    The Lost Cursor

    Has this been fixed too?
  12. Anyone written one of these that i can have a copy of or maybe someone could add this to the 'extra plugins' pack ?
  13. TomF

    The Lost Cursor

    Also, when double-clicking a file to open it, the file opens, but the focus remains on the file browser, so scrolling with the mouse wheel scrolls the file browser pane left and right (which is totally pointless!!) Instead, the cursor should be placed at the start of the newly opened file, then scrolling with the mouse wheel will scroll the newly opened file. I asked for this years ago, but it never happened.
  14. I've managed to come up with a better solution. However, on the way i found that rom char L1Values[] = {3, 10, 20, 30, 40, 50}; produces different RAM and ROM usage to rom char* L1Values = {3, 10, 20, 30, 40, 50};
  15. microchip state the 12f683 has 3.5k rom, boostc is saying it has 2k. Edit: Microchip are wrong, their product lineup chart is wrong - doh! The datasheet states 2048 as does SB
  16. hi, It looks like the switch statment default: return false; is being ignored? char a = 1; switch(a) { default: return; case 2: a = 3; break; } Setup_Init(); CASM char a = 1; 03C5 3001 MOVLW 0x01 03C6 1283 BCF STATUS, RP0 03C7 00D0 MOVWF Setup_Run_00000_1_a switch(a) { default: return; case 2: 03C8 0850 MOVF Setup_Run_00000_1_a, W 03C9 3A02 XORLW 0x02 03CA 1D03 BTFSS STATUS,Z a = 3; 03CC 3003 MOVLW 0x03 03CD 00D0 MOVWF Setup_Run_00000_1_a break; } Setup_Init(); 03CE 2353 CALL Setup_Init_00001 Also, in another switch statment in my program, the generated code has this at the end: Is this correct? 4 return statments? CASM return true; 024D 3001 MOVLW 0x01 024E 00E9 MOVWF CompTempVarRet636 }// end of switch 01E2 0008 RETURN 01E8 0008 RETURN 01F5 0008 RETURN 024F 0008 RETURN
  17. The compiler has now given up initilising the function pointer too, so i removed it, and changed the unsigned short* to a unsigned char* and that is also being rejected. Seems like initilised structs just are not working at all. Any idea when this will be fixed, im really up against a wall here and i dont really have time to sort out and keep working around compiler bugs- i just need to code the application in C, test and release!
  18. I've managed to work around the issue now. I wrote a function that copies the required array into RAM before use. This is not ideal as its using RAM, and requires a block the same size as the array in ROM! but for my app, its only a max of 10 bytes. I can see why storing strings would be a pain though... Can you write up your solution? might be of some help in another project i have going on. TIA.
  19. Is that being looked at too? I need to store a large array of data, and its used all my RAM up! Its the L1Values and L2Values that need to go into ROM. I tried, but the compiler complained because they are shorts, not bytes.
  20. Ah mate, thanks for the reply. Been pulling my hair out!! Can the members of the struct be declaired const so they are stored in ROM (once you've fixed it). No sence in having any of the arrays in ram!
  21. Hi, Any ideas? seems to give up on the unsigned short pointers... "C:\Program Files\SourceBoost\boostc_pic16.exe" -t PIC12F683 LiteCtrl.c Setup.c BoostC Optimizing C Compiler Version 6.96 (for PIC16 architecture) F:\projects\Software\Setup.c(37): error: can't convert 'unsigned short*' to 'sSetupSettings' #define ARRAY_ELEMENT_COUNT(arrayname) (sizeof(arrayname) / sizeof(arrayname[0])) static unsigned short param1 = 1; static unsigned short param2 = 2; void Setup1Callback(); void Setup2Callback(); unsigned short L1Values[] = {3, 10, 20, 30, 40, 50}; unsigned short L2Values[] = {1, 10, 20, 30, 40, 50, 60}; typedef void(*SETUP_CHANGE_CALLBACK)(); typedef struct { // Everything in this structure is read only. SETUP_CHANGE_CALLBACK callback; unsigned char ucEepromAddr; unsigned short* pParam; unsigned short* pParamValidValues; unsigned char ucNumParamDataElements; }sSetupSettings; sSetupSettings m_SetupSettings[] = { { Setup1Callback, 0x03, &param1, L1Values, ARRAY_ELEMENT_COUNT(L1Values) }, { Setup2Callback, 0x05, &param2, L2Values, ARRAY_ELEMENT_COUNT(L2Values) } };
  22. It's better -- I think the optimiser needs more work. test_bit(gpio, 4) ? bit1 = 1 : bit1 = 0; 0003 1283 BCF STATUS, RP0 0004 1E05 BTFSS gbl_gpio,4 0005 2808 GOTO label1 0006 1420 BSF main_1_bit1,0 0008 label1 0008 1020 BCF main_1_bit1,0
  23. // Clear bit, test and change if required. bit bit1=0; if( test_bit(gpio, 4) ) { bit1 = 1; } 0010 1283 BCF STATUS, RP0 0011 1026 BCF main_1_bit1,0 0012 1A05 BTFSC gbl_gpio,4 0013 1426 BSF main_1_bit1,0 // Use if else to set or clear bit. bit bit1; if( test_bit(gpio, 4) ) { bit1 = 1; } else { bit1 = 0; } 0010 1283 BCF STATUS, RP0 0011 1E05 BTFSS gbl_gpio,4 0012 2815 GOTO label1 0015 label1 0013 1426 BSF main_1_bit1,0 0014 2816 GOTO label2 0016 label2 0015 1026 BCF main_1_bit1,0 // Use tenary operator to set or clear bit (same as if else?) bit bit1; bit1 = test_bit(gpio, 4) ? 1:0; 0010 1283 BCF STATUS, RP0 0011 1E05 BTFSS gbl_gpio,4 0012 2815 GOTO label1 0013 14A6 BSF CompTempVar524,1 0014 2816 GOTO label2 0015 label1 0015 10A6 BCF CompTempVar524,1 0016 label2 0016 1026 BCF main_1_bit1,0 0017 18A6 BTFSC CompTempVar524,1 0018 1426 BSF main_1_bit1,0
  24. Anyone know how to solve this???? Linking... "C:\Program Files\SourceBoost\boostlink.pic.exe" /ld "C:\Program Files\SourceBoost\lib" libc.pic16.lib LiteCtrl.obj /t PIC12F683 /d "E:\projects\Software" /p LiteCtrl BoostLink Optimizing Linker Version 6.84 http://www.sourceboost.com Copyright© 2004-2007 Pavel Baranov Copyright© 2004-2007 David Hobday Warning unreferenced functions removed: InternalEepromRead in: Internal Eeprom.h failure Linker Internal Error: Cant find Goto destination Done
  • Create New...