Jump to content

joli

EstablishedMember
  • Content Count

    85
  • Joined

  • Last visited

Community Reputation

0 Neutral

About joli

  • Rank
    Regular

Profile Information

  • Gender
    Male
  • Location
    Portugal

Recent Profile Visitors

632 profile views
  1. Answering to my self. Its working now. Under mplabx the libraries should be added to the project through Project Properties and add it to BoostLink / Additional options. By the way, the compiler/linker finish the job in about 3 minutes > 72 module_files / 273 functions - 4 core, i7, 2.8GHZ, 16gb_ram The compiler takes 30 seconds. The rest of the time is spent by the linker (2.5 minutes)... It would be great if linker could be improved.
  2. #include <system.h> typedef unsigned char uchar; void main() { uchar j=20; uchar i = (j/10); } Compiling the little snipet above under mplabx, it return errors like this: Error: Unresolved external function:'__div_8_8(unsigned char,unsigned char)' depending of the evaluated expression the error could be: Error: Unresolved external function:'__div_16_16(unsigned char,unsigned char)' Surprinsingly, the same not happens to 16/32 bit multiplications. The solution is to include libc.pic16.lib or libc.pic18.lib, depending the pic family we are using. This could be done, under mplabx/File/Project Properties. Now in the Project Properties Window, select Libraries and Add Library/Object File, choose <libc.pic1x.lib> and thats it. Alternately, it can be done following the procedure above but picking Linker instead Libraries and add <libc.pic1x.lib> in the Additional Options. P.S. the same procedure works with floats.
  3. Is there any trick for float lib to work with mplab x? The code below compiles ok in sourceboost editor but not in mplabx. #include <system.h> #include <float.h> void main() { float f = float32_mul(2.5, 2.5); } Here is some errors when compiling this code in mplabx ide: Error: Unresolved external function:'__mul_32_32(unsigned long,unsigned long)' ... same error above repeated n times ! Error: Unresolved external symbol, function:__mul_32_32 ... same error above repeated n times ! make[2]: *** [dist/default/production/float.X.production.hex] Error -2 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 BUILD FAILED (exit value 2, total time: 5s) float.pic18.lib was included as explained in the FoatMath.pdf page 9 PIC18LF67K40 / c++ pro licence / sourceboost 4.43 / mplab x 4.15
  4. Hi there, As far as I can see, J94 types are not supported and I have no idea if the compiler will continue to be upgraded or not. The 18(l)fxxk40 types, they are supported, but the header files are incomplete, so i wrote a simple tool to generate them from the "inc" files included in the mplabx/v4.10/mpasmx. I can put them here if the owners of sourceboost allow me to... i have no idea about legal stuff. Optionally it can be done by modifying the files provided by microchip, using an editor with macros in order to turn the job less painfull... for instance, p18lf67k40 has about 6700 lines. regards
  5. try this out instead of your #pragma's: // FUSES #pragma config OSC = INTOSCPLL // Internal osc PLL can be enable/disable #pragma config CP0 = OFF // Program memory is unprotected #pragma config FCMEN = ON // Enable osc monitor #pragma config WDTEN = OFF // Watchdog OFF #pragma config WDTPS = 512 // 1:512 #pragma config XINST = OFF // Disable extended instruction set (mandatory) #pragma config IOL1WAY = OFF // works either way
  6. There is a clean crc16 code, based in the example given in the sourceboost / examples, to all that needs it The code is working pretty well in a real app that uses several industrial modbus devices. // crc16 table hi/lo rom char *aucCRCHi = { 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 }; rom char *aucCRCLo = { 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x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x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80, 0x40 }; uint CRC16( uchar *pucFrame, uchar usLen ) { uchar ucCRCHi = 0xFF; uchar ucCRCLo = 0xFF; uint iIndex; while( usLen-- ) { iIndex = ucCRCLo ^ *( pucFrame++ ); ucCRCLo = (uchar)( ucCRCHi ^ (uchar)aucCRCHi[iIndex] ); ucCRCHi = (uchar)aucCRCLo[iIndex]; } return (uint)( ucCRCHi << 8 | ucCRCLo ); } br
  7. I did an atempt to use this in a real application by using several lists of structures but the compiler boostc/bostc++, failed. After several tests i concluded that the compiler do doesn't like to have "methodes" inside of the structure. So, until better oppinion, i believe that this is a compiler issue. Modifications: 1. delete AddStudent( uchar *pstudent ) "methode" inside of structure. 2. instead of StuList.AddStudent( adata ), StuList.s_id = data[0] and StuList.s_age = data[1] should be used. br
  8. Same here with xp, vista, w7, w10. I remember that this worked in previous versions, 6.97 for instance. br
  9. ANDYp, looking at datasheet, timer 1 section, i can't see how to achieve 20 minutes with timer 1 interrupt... lets see: clock = 4000000 Hz maximum prescaler = 8 maximum timer 1 count = 65536 t1_tick = 1 ( 4000000 / 4 / 8 / 65536 ) = 0.524288 secs But it can be used by polling the timer 1 interrupt flag and count the number of times that the TMR1IF rises. To achieve 20 mins the number of counts is 20*60/ t1_tick = 2288 Then you can call your function to change state or whatever you want timer 1 interrupt isn't need, polling pir1.TMR1IF is enough. write a function to do it and call this function from main. If my math is right it should work pretty well br
  10. im glad you got it working. about Dave and Pavel, i see no activity from him in here for a long time. but company keep selling cause i brought a boostc++ pro weeks ago i don't know what that absence means, i just know that in my oppinion they have a great product with a very competitive price br
  11. Forgot to mention the basis of it is on boostc++ manual page 83. br
  12. With just the code fragment you show is not possible to comment. http://www.microchip.com/forums/m816748.aspx http://ww1.microchip.com/downloads/en/AppNotes/00000734C.pdf br
  13. Another way to do the same with less code on set/clear output, imagining that the Green output is a led with cathode connected to the ground This is also faster than previous example because just one instruction is needed to change the output state #include <system.h> #define GREEN 1 // Green pin gpio = (1<<GREEN); // precondition(HI) when triso.1 = 0 (as output) trisio = ~(1<<GREEN); // all pins = inputs except for GREEN pin = output // macro #define SET_GREEN_HI ( trisio &= ~(1<<GREEN)) // <=> trisio.GREEN=0 #define SET_GREEN_LO ( trisio |= (1<<GREEN)) // <=> trisio.GREEN=1 void main( void ) { SET_GREEN_HI; // turn Green out = high SET_GREEN_LO; // turn Green out = low } reedited: Forgot to mention that this issue only happens when u want to modify one or more port pin state(not the entire port). This means if u write the entire port, mirror is not needed, but as a rule for devices without latx i use to write everything through the mirror. hope this helps, br
  14. A more elegant way to do the same... // header file #ifndef _STUDENTS_H_ #define _STUDENTS_H_ typedef unsigned char uchar; #define STUDENTS 64 // S T U D E N T D A T A S T R U C T struct Student { uchar s_id; // id uchar s_age; // age void AddStudent( uchar *pstudent ) // add function member { s_id = *pstudent++; s_age = *pstudent; } }; extern Student StuList[STUDENTS]; // turn it global if need #endif // c file #include <system.h> #include "students.h" Student StuList[STUDENTS]; void main() { uchar adata[2]; for( uchar i=0; i<STUDENTS; i++ ) // all 64 elements { adata[0] = i+1; // data to be stored adata[1] = i+1; StuList[i].AddStudent( adata ); } } br
  15. Actually is not so hard set config fuse bits, unless you are using on of the rare devices that comes with missing defines. In that case you need to write all defines in the include file Anyway, it depends of device you are using Here is an example for pic18f4620 #pragma config CP0 = OFF // Code Protection bits (Program memory code protection off) #pragma config OSC = INTIO67 //XT // Oscillator Selection bits (RC oscillator w/OSC2 configured as RA6) #pragma config IESO = OFF // Oscillator System Clock Switch Enable bit (Oscillator system clock switch option is disabled (main oscillator is source)) #pragma config PWRT = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config BOREN = ON // Brown-out Reset Enable bit (Brown-out Reset enabled) #pragma config BORV = 0 // Brown-out Reset Voltage bits (VBOR set to 2.5V) #pragma config WDT = ON // Watchdog Timer Enable bit (WDT enabled) #pragma config WDTPS = 128 // Watchdog Timer Postscale Select bits (1:128) #pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit (Stack Full/Underflow will cause RESET) if i remember, when we start a new project using the sourceboost wizard, "he" do it for us, but this feature not cover all devices.... again... since i remember br
×