Jump to content

ajcrm125

Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral

About ajcrm125

  • Rank
    Newbrie

Contact Methods

  • Website URL
    http://www.onecircuit.com
  • ICQ
    0
  1. Unfortunately I'm working with the PIC12F508 which I don't think BoostC supports right?
  2. Could also be a problem elsewhere, but as of now I'm only experimented with a switch statement. It seems that the break statement will not break out of a case within a switch if the break is contained inside curly braces. For example: //#include <system.h> #define INIT 0 #define STATE1 1 #define STATE2 2 #define STATE3 3 char state; char nextState; main() { state = 0; while(1) { switch (state) { case INIT : { nextState = STATE1; break; } case STATE1 : { nextState = STATE3; break; } case STATE2 : { nextState = STATE1; break; } case STATE3 : { nextState = STATE2; break; } default : nextState = INIT; } } } If you compile this the assembly looks like this: ;;;;;;;;//#include <system.h> ;;;;;;;;char state; ;;;;;;;;char nextState; ;;;;;;;; ;;;;;;;; ;;;;;;;;main() _main__code ;;;;;;;;{ ;;;;;;;; state = 0; clrf _state ;;;;;;;; ;;;;;;;; while(1) label_0000 ;;;;;;;; { ;;;;;;;; switch (state) movf _state, W movwf _code_tmp_0000 ;;;;;;;; { ;;;;;;;; case 0 : { movf _code_tmp_0000 , W sublw D'0' btfss STATUS, Z goto label_0003 label_0004 ;;;;;;;; nextState = 1; movlw D'1' movwf _nextState ;;;;;;;; break; ;;;;;;;; } ;;;;;;;; case 1 : { label_0003 movf _code_tmp_0000 , W sublw D'1' btfss STATUS, Z goto label_0005 label_0006 ;;;;;;;; nextState = 3; movlw D'3' movwf _nextState ;;;;;;;; break; ;;;;;;;; } ;;;;;;;; case 2 : { label_0005 movf _code_tmp_0000 , W sublw D'2' btfss STATUS, Z goto label_0007 label_0008 ;;;;;;;; nextState = 1; movlw D'1' movwf _nextState ;;;;;;;; break; ;;;;;;;; } ;;;;;;;; case 3 : { label_0007 movf _code_tmp_0000 , W sublw D'3' btfss STATUS, Z goto label_0009 label_0010 ;;;;;;;; nextState = 2; movlw D'2' movwf _nextState ;;;;;;;; break; ;;;;;;;; } ;;;;;;;; default : nextState = 0; label_0009 clrf _nextState ;;;;;;;; } ;;;;;;;; } label_0002 ;;;;;;;; ;;;;;;;;} goto label_0000 label_0001 _main__end const_ptr_data END As you can see, the break is essentially ignored. If you leave out the curly braces, compiles to this: ;;;;;;;;//#include <system.h> ;;;;;;;;char state; ;;;;;;;;char nextState; ;;;;;;;; ;;;;;;;; ;;;;;;;;main() _main__code ;;;;;;;;{ ;;;;;;;; state = 0; clrf _state ;;;;;;;; ;;;;;;;; while(1) label_0000 ;;;;;;;; { ;;;;;;;; switch (state) movf _state, W movwf _code_tmp_0000 ;;;;;;;; { ;;;;;;;; case 0 : movf _code_tmp_0000 , W sublw D'0' btfss STATUS, Z goto label_0003 ;;;;;;;; nextState = 1; label_0004 movlw D'1' movwf _nextState ;;;;;;;; break; goto label_0002 ;;;;;;;; ;;;;;;;; case 1 : label_0003 movf _code_tmp_0000 , W sublw D'1' btfss STATUS, Z goto label_0005 ;;;;;;;; nextState = 3; label_0006 movlw D'3' movwf _nextState ;;;;;;;; break; goto label_0002 ;;;;;;;; ;;;;;;;; case 2 : label_0005 movf _code_tmp_0000 , W sublw D'2' btfss STATUS, Z goto label_0007 ;;;;;;;; nextState = 1; label_0008 movlw D'1' movwf _nextState ;;;;;;;; break; goto label_0002 ;;;;;;;; ;;;;;;;; case 3 : label_0007 movf _code_tmp_0000 , W sublw D'3' btfss STATUS, Z goto label_0009 ;;;;;;;; nextState = 2; label_0010 movlw D'2' movwf _nextState ;;;;;;;; break; goto label_0002 ;;;;;;;; ;;;;;;;; default : nextState = 0; label_0009 clrf _nextState ;;;;;;;; } ;;;;;;;; } label_0002 ;;;;;;;; ;;;;;;;;} goto label_0000 label_0001 _main__end const_ptr_data END and behaves as expected. I've loaded the C source into MS Visual C++ and both variations behave as expected so it looks like there's a dependancy on the break statement and curly braces for C2C Plus.
  3. Okay.. just downloaded SourceBoost IDE etc and started a new project using C2CPlus and a PIC12C508A as my target device. Only thing missing is I don't know how to access the TRIS register so I can configure the GPIO port functions. Any help? Thanks...
×
×
  • Create New...