Jump to content

rminnig

EstablishedMember
  • Content Count

    16
  • Joined

  • Last visited

Community Reputation

0 Neutral

About rminnig

  • Rank
    Newbrie
  1. Has anyone ever done a downgrade of the BoostC compiler? The reason I ask is because I have a client that wants to make source code changes to a product that is in production since 2007. As far as I can tell from the listing file: ;// Code Generator: BoostC Compiler - http://www.sourceboost.com ;// Version : 6.35 is the version they used, but when I try to compile the source code with 7.10, the listing file is so different that BeyondCompare shows all red for nearly the whole of the compare. What I'm trying to do is verify that the HEX file they use was generated from a specific source codes before I make any changes because I don't want to inadvertently introduce and unknown "small fix" because their documentation that tracks software versions to compiler versions is non-existant (no SVN :-() If anyone has a different plan other than a downgrade to confirm a set of source code to a HEX file, I'm open to that as well.
  2. What am I doing wrong? I'm using the 16LF819. The generated assembly follows with the original C++ code ;;;;;;commented by the code generator. I've tried two methods, one with testing the bit, one with testing the compliment of the bit. The purpose of this one line of code is to test the state of the GO bit in adcon0, continue to loop if the bit is set, break out of the loop when the bit goes clear (i.e. the hardware clears this bit when AD conversion is complete) ;;;;;;;; while (!(adcon0 & (0x01<<2))) {;} //wait for conversion complete label_0000 movf _adcon0, W andlw D'4' btfss STATUS, Z goto label_0001 ;;;;;;;; chResult1 = adresh; goto label_0000 label_0001 code continues... ;;;;;;;; while (adcon0 & (0x01<<2)) {;} //wait for conversion complete label_0000 movf _adcon0, W andlw D'4' sublw 0 btfsc STATUS, Z goto label_0001 ;;;;;;;; chResult1 = adresh; goto label_0000 label_0001 code continues...
  3. Either way I write the commented line the generated code seems not to work properly. The code should test the 'GO' bi tin ADCON0 and if the bit is not cleared (i.e. AD conversion not complete) then just stay in the while loop. When the bit goes clear then the while statement should fail and jump out fo the loop. What am I doing wrong. I've included the generated assembly code, the original source code line is ;;;;;;;;;commented. ;;;;;;;; while (!(adcon0 & (0x01<<2))) {;} //wait for conversion complete label_0000 movf _adcon0, W andlw D'4' btfss STATUS, Z goto label_0001 ;;;;;;;; chResult1 = adresh; goto label_0000 label_0001 code continues... ;;;;;;;; while (adcon0 & (0x01<<2)) {;} //wait for conversion complete label_0000 movf _adcon0, W andlw D'4' sublw 0 btfsc STATUS, Z goto label_0001 ;;;;;;;; chResult1 = adresh; goto label_0000 label_0001 code continues...
  4. Remember mechanical switches require a debounce or you will see many "button transisitons" if you are just looking at the edges. Here is my code, subsitute any port or pin within that port into the initial if statement. This code assumes that the system is providing a periodic 'tick' to the tick method. You can also do this with a timer if you wish. cpp file: #include "PushButton.h" #include "p16f818.h" // Constructs a Task object. CPushButton::CPushButton() { bButtonPressed = false; bButtonHeld = false; chButtonIterations = 0; } void CPushButton::tick(void) { char ch = portb; if (ch & 0x01) { chButtonIterations++; } else //Reset the counter { chButtonIterations = 0; } // Check if a press or a hold for button 0, NOTE press and hold are mutually exclusive if (chButtonIterations > nIterationsToBeAPress) { bButtonPressed = true; bButtonHeld = false; } else if (chButtonIterations > nIterationsToBeAHold) { bButtonPressed = false; bButtonHeld = true; } else { bButtonPressed = false; bButtonHeld = false; } } h file #ifndef PushButton_H #define PushButton_H // this define simply defines the word bool as a char to make the code look nicer using booleans for flags. #define bool char #define nIterationsToBeAPress 5 #define nIterationsToBeAHold 100 class CPushButton { public: CPushButton(); void tick(void); char chTickCounter; bool bButtonPressed; bool bButtonHeld; char chButtonIterations; }; #endif /* PushButton_H */
  5. Can you either post or email me the generated assembler file? That should give a clue as to what the processor is doing with the pins on port b and timing.
  6. There is a serious code generation error with the C2C++ compiler. Note the generated assebly snippet: ... _adresl equ 0x9e ;1 _adcon1 equ 0x9f ;1 _eedata equ 0x10c ;1 _eeadr equ 0x10d ;1 _eedath equ 0x10e ;1 _eeadrh equ 0x10f ;1 _eecon1 equ 0x18c ;1 _eecon2 equ 0x18d ;1 _this_tick_CPWM_00 equ 0xffffffff ;2 ORG 0 goto start__code ORG 4 ;;;;;;;; ;;;;;;;;// The 16F818 has only 1 interrupt vector ;;;;;;;; ;;;;;;;;void interrupt(void) _interrupt _interrupt_code movwf _int_save_cont_W swapf _int_save_cont_W, F swapf STATUS, W movwf _int_save_cont_STATUS ... and when the above is manually changed to: ... _adresl equ 0x9e ;1 _adcon1 equ 0x9f ;1 _eedata equ 0x10c ;1 _eeadr equ 0x10d ;1 _eedath equ 0x10e ;1 _eeadrh equ 0x10f ;1 _eecon1 equ 0x18c ;1 _eecon2 equ 0x18d ;1 _this_tick_CPWM_00 equ 0x18e ;2 ORG 0 goto start_code ORG 4 ;;;;;;;; ;;;;;;;;// The 16F818 has only 1 interrupt vector ;;;;;;;; ;;;;;;;;void interrupt(void) _interrupt _interrupt_code movwf _int_save_cont_W swapf _int_save_cont_W, F swapf STATUS, W movwf _int_save_cont_STATUS ... it works. The exact same code works for about a hundred compiles during the day, buat after some amount of time in the same project the code all of a sudden gets messed up as in the bolded lines above. If the EXACT same code is duplicated in a new project then it compiles without error. Any ideas on this one? Note because of a bug in the forum some of the double underscores in the generated assembly have been trucated to singel underscores. -Ryan
  7. Why does this work? #define bool char #define false 0 #define true 1 bool b8HzModulation = false; b8HzModulationIsOn ^= true; //toggle and this doesn't? #define bool char #define false 0 #define true 1 bool b8HzModulation = false; b8HzModulationIsOn ~= b8HzModulationIsOn; // should toggle, but doesn't In the example "osExample.cpp" I see the statement which I presume works: m_ledState = ~m_ledState; -Any Ideas?
  8. You cannot use the example you have exactly. I don't know if the standard string library is included in C2C(++), but if it is you can use something like this: char pch1[5] = "hi"; char pch2[5]; //presumably, something in this array if (strcmp (pch1, pch2)) { //do something useful } If the string library is not included you should be able to find source code for it on the net somewhere. Not like it's all that original or secretive code anyway. Hope this helps. -Ryan
  9. You mean, this is ALMOST absolutely correct. Some of the 18 series parts, i.e. the 18F452 allow reading of IDLOCS during normal execution through the TBLRD and TBLWT assembly instructions. Most other parts do not allow acces during normal execution, check with the data sheets for the part you are working with. Check out the data sheets from the microchip website, DS39564B.pdf (Datasheet for the 18FXX2).
  10. I would suggest posting your code so we can help you learn what might be wrong with it.
  11. You can not have 2 different ISRs on this chip. The 18 series chips hava a high priority and low priority interrupt that can have 2 different vectors. With 1 ISR you can do something like this: void interrupt( void ) { if ( //check to see if souce was timer 0) { } else if ( //check to se if source was RBIF) { } else if ( //check to see if source was INTF) { } else //it was a false alarm, or no code implemented } and you can order your if-else statemtns in the priority that you want to check. -Ryan
  12. Why do you need those variables at a specific address? You can also try using a union: union { short s; char ch[2]; }u; Then access the varibles like this: u.s = 12345; char var1 = u.ch[0]; char var2 = u.ch[1]; Hope this helps.
  13. The following code whould compile just fine, but gives me a stupid error every time. This exact same code compiles with the MSVC++ v6 SP5 compiler. enum eLEDPort { LED_ON_PORTA = 0x01, LED_ON_PORTB }; I've ended up using a work around: //enum eLEDPort //{ #define eLEDPort char #define LED_ON_PORTA 0x01 #define LED_ON_PORTB 0x02 //}; Why doesn't the first code example compile? I get error: LED.h(38): '(' expected The enum statement is on line 38 in the header file.
×
×
  • Create New...