Jump to content

All Activity

This stream auto-updates     

  1. Yesterday
  2. Incorrect code generated

    Thanks Pavel. Unfortunately the Chameleon compiler does not support C++ (does it?) Regards Tim
  3. Incorrect code generated

    I can confirm this issue for the BoostC compiler family. The Chameleon compiler however handles this code well. Regards, Pavel
  4. Last week
  5. 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
  6. Earlier
  7. 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
  8. Incorrect code generated

    Bug description: The compiler generates incorrect code for the following statement - while (c -= 1) Steps to reproduce: My source code is this - #define BSIZE 120 unsigned char RxBuffer[BSIZE]@0x100; unsigned char TxBuffer[BSIZE]@0x200; unsigned char RamSwapArea[16U]@0x300; void main() { asm lfsr 1, _RxBuffer asm lfsr 2, _TxBuffer unsigned char c = BSIZE; while (c -= 1) { asm movff _postinc1, _postinc2 } } The bug is the statement "while (c -= 1)" generates an INFSNZ instruction, even though variable c is being decremented. Here is the disassembly listing - 13: #define BSIZE 120 14: unsigned char RxBuffer[BSIZE]@0x100; 15: unsigned char TxBuffer[BSIZE]@0x200; 16: unsigned char RamSwapArea[16U]@0x300; 17: 18: void main() 19: { 20: asm lfsr 1, _RxBuffer 0008 EE11 LFSR 1, 0x100 000A F000 NOP 21: asm lfsr 2, _TxBuffer 000C EE22 LFSR 2, 0x200 000E F000 NOP 22: 23: unsigned char c = BSIZE; 0010 0E78 MOVLW 0x78 0012 6E01 MOVWF c, ACCESS 24: while (c -= 1U) 0014 4A01 INFSNZ c, F, ACCESS 001C D7FB BRA 0x14 25: { 26: asm movff _postinc1, _postinc2 0018 CFE6 MOVFF POSTINC1, POSTINC2 001A FFDE NOP 27: } 28: } 0016 0012 RETURN 0 Expected behaviour: The instruction at address 0014 should be 'DCFSNZ c, F, ACCESS Is the problem 100% reproduceable: 100% every time IDE version: MPLAB-X 4.15 (64-bit) Compiler: BoostC++ Optimizing C++ Compiler Version 7.43 (for PIC18 architecture) Compiler version: V7.43 Target device: PIC18F8527 OS: Windows 10 Pro 64-bit Comments: Have included the source files - main.cpp
  9. thanks. got it.
  10. Go to the Microchip web site. Select the page for your chip (PIC16F1788). Select the documentation tab and it's under Programming Specifications.
  11. I apologize for perhaps a dumb question, but what programming manual?
  12. Hi mityeltu, The programming manual page 35 suggests the base address for EEPROM is at 1E00h. Cheers Reynard
  13. I am making new .h and .tdf files for the 16f1788 chip that I wan to use for a new project. Why I wan to use this chip as opposed to another that might already have these files built is not important for this discussion. I have run through the .h file and am at the last section, but I don't understand where I can find the eeprom base address that is used in any of the existing .h files. For instance, the file for the 16f1783 that I am using as a template calls out the address as 0xf000. I can't find this information anywhere in the datasheet for this chip. Where can I find it? Is it always the same? If not, how can I verify the location for the chip I am currently working on? Can anyone tell me what section it's in?
  14. Is there a way to duplicate an assembly language macro that I use to store constant strings inline with my code? The putstr() function pulls the return address (the string address in this case) from top-of-stack, sends the string while updating TOS, and returns to the instruction immediately following the inline string. Here's the assembly language version I'm trying to duplicate; putstrg macro string ; in-line rom string call putstr ; inline string print function dt string,0 ; inline string endm ; Here's the inline print string function... /******************************************************************** * * ********************************************************************/ void putstr() // in-line strings (14 words) { strloop: // bank 31 (inserted by compiler) |31 asm movf _tosl,W // copy return address to FSR1 |31 asm movwf _fsr1l // " |31 asm movf _tosh,W // " |31 asm movwf _fsr1h // " |31 asm bsf _fsr1h,7 // set b7 for access to flash |31 asm incf _tosl,F // bump return/string address |31 asm btfsc _status,Z // " |31 asm incf _tosh,F // " |31 asm movf _indf1,W // end-of-string (0x00)? |31 asm btfsc _status,Z // no, skip (send char), else |31 asm return // exit (end-of-string) |31 asm call putwreg() // data passed in wreg |31 asm bra strloop // |31 } Thank you all for your time and kind consideration. Cheerful regards, Mike, K8LH
  15. Where's Chameleon?

    Go to Settings menu and select Toolsuite… There you will find Chameleon. Cheers Reynard
  16. I have looked all over the site and other somewhat disreputable sites looking for the Chameleon compiler that is mentioned every time I build a project with BoostC++. I can't seem to find it anywhere. Where do i go to get it?
  17. 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
  18. I'll have to check that tomorrow, but if I recall from the scope, I was not generating the interrupt on the positive edge of the pwm cycle. I'll check that tomorrow
  19. 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
  20. I am using the PWM, but a 50% duty cycle is what needs to be there due to the discharge of the capacitor after it charges. If I lengthen the DC, then the cap may not discharge enough for the next charge cycle and the timing will be messed up. I also found out that the comparator interrupts on any change in the output. I dodn't know that up front, so I can use the discharge interrupt to setup for the next charge cycle. I realize that I'm using tmr2 for the pwm, but there does not seem to be a good way of using that to catch the beginning of the pwm cycle. I have fed the pwm output into INT0 and this seems to work, but I suspect there is a better way. i don't understand how to use tmr2 to catch the pwm leading edge, but either way it will wind up being an interrupt, so whether a tmr2 or INT0 I guess doesn't really matter. What do you think?
  21. 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
  22. I am attempting to make an ohmmeter out of this chip by pulsing a pin using PWM. The pin has a resistor capacitor series network. The resistor is the unit under test. I can use tmr3 to get the time to reach a specific voltage level (1T = 0.63 x VDD) and can interrupt when the comparator trips, but how do I catch the start of the pulse? Is there an interrupt for pulse start or am I goign to need to feed the PWM signal into an external int? Or maybe one of you smart guys has a better way. Any thoughts?
  23. Yes you can share the compiled libc binary but not the library sources. Please make sure the github users know the origin of the binary. Regards, Pavel
  24. One of my open source projects requires a custom PIC18 libc. Am I allowed to share a compiled libc binary?
  25. 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
  26. We would like to reproduce this and we don't need your source code. Please email your project obj files and linker command line to support@sourceboost.com Regards, Pavel
  27. 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.
  28. #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.
  1. Load more activity
×