Expected: ; error on const decliration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Expected: ; error on const decliration

1,824 Views
NZ_Design
Contributor I
I are trying to declear a const array of pins on the processor for the purpose setting and clearing them from a pointer in a loop.
 
I get this error
 
Error   : C2450: Expected:  ;
Output Control.c line 7  
Error   : Compile failed
 
here is how I have done it.
 
#pragma CONST_SEG __PPAGE_SEG MY_CONST
const Output_Address[MAX_OUTPUTS] = { PTT_PTT7,   // Output A1
                                PTT_PTT6,   // Output A2
                                PTT_PTT5,   // Output A3
                                PTT_PTT4,   // Output A4
                                PORTB_BIT3, // Output A5
                                PORTB_BIT2, // Output A6
                                PORTB_BIT1, // Output A7
                                PTJ_PTJ0,   // Output A8
                                PTT_PTT3,   // Output B1
                                PTT_PTT2,   // Output B2
                                PTT_PTT1,   // Output B3
                                PTT_PTT0,   // Output B4
                                PORTB_BIT0, // Output B5
                                PTJ_PTJ1,   // Output B6
                                PORTK_BIT4, // Output B7
                                PORTK_BIT5};// Output B8
#pragma CONST_SEG DEFAULT
 
 
What are I doing wrong.
Labels (1)
0 Kudos
1 Reply

207 Views
Sten
Contributor IV
You have declared Output_Address as a const integer and you try to initialize it with references to single bits, which does not work.
 
A way to do what you want would be the following (untested, but should give the idea how to do it):
 
Code:
const struct {   unsigned char *addr;   unsigned char mask;} Outputs[MAX_OUTPUTS] = {   { &PTT, PTT_PTT7_MASK },   { &PTT, PTT_PTT6_MASK },    ...   ...   { &PORTK, PORTK_PK5_MASK }};void clear_outputs(void) {   int i;   for (i = 0; i < MAX_OUTPUTS; i++) *Outputs[i].addr &= ~Outputs[i].mask;}void set_outputs(void) {   int i;   for (i = 0; i < MAX_OUTPUTS; i++) *Outputs[i].addr |= Outputs[i].mask;}

 
Sten
 
0 Kudos