Home > other >  [for a belt operation] with operating address in the array, implementation while training in rotatio
[for a belt operation] with operating address in the array, implementation while training in rotatio

Time:10-31

Doing a 17 core cable on-off testing procedures, using 10 OUT and 10 IN mouth, mouth OUT, IN turn, control the output level of on any account, want to put OUT the mouth with the address IN the array, consult how to implement? Operation of pointer and a pointer into an array of operation is not familiar, please teach,

The code is as follows:
* * * * * the following header file:
# define LINE_NUM_SUM 17

# define OUT0 PAout (0)
# define OUT1 PBout (1)
# define OUT2 PBout (2)
# define OUT3 PBout (3)
# define OUT4 PBout (4)
# define OUT5 PAout (5)
# define OUT6 PBout (6)
# define OUT7 PBout (7)
# define OUT8 PBout (8)
# define OUT9 PBout (9)
# define OUT10 PBout (10)
# define OUT11 PBout (11)
# define OUT12 PBout (12)
# define OUT13 PBout (13)
# define OUT14 PBout (14)
# define OUT15 PBout (15)
# define OUT16 PAout (6)
# define OUT17 PAout (7)

* * * * * * * * * * the following C file

Void checkInit ()
{
U8 I=0;
GPIO_InitTypeDef GPIO_Initure;

__HAL_RCC_GPIOA_CLK_ENABLE ();//open GPIOB clock
__HAL_RCC_GPIOB_CLK_ENABLE ();//open GPIOE clock
__HAL_RCC_GPIOC_CLK_ENABLE ();//open GPIOE clock

//OUT initialization
GPIO_Initure. Pin=GPIO_PIN_0 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7;//0 5 6 7
GPIO_Initure. Mode=GPIO_MODE_OUTPUT_PP;//push-pull output
GPIO_Initure. Pull=GPIO_PULLDOWN;//dropdown
GPIO_Initure. Speed=GPIO_SPEED_FREQ_HIGH;//high speed
HAL_GPIO_Init (GPIOA, & amp; GPIO_Initure);//GPIOA OUT

GPIO_Initure. Pin=GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4;//1 2 3 4
GPIO_Initure. Pin |=GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9;//6 7 8 9
GPIO_Initure. Pin |=GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;//10 11 12 13
GPIO_Initure. Pin |=GPIO_PIN_14 | GPIO_PIN_15;//14 15
HAL_GPIO_Init (GPIOB, & amp; GPIO_Initure);//GPIOB OUT

//test OUT whether cycle output
While (I & lt; LINE_NUM_SUM)
{
If (OUTThis [I])
OUTThis [I]=0;
The else
OUTThis [I]=1;

Delay_ms (1000);
}
}

CodePudding user response:

Why bother?

Data is generated by a variable polling, directly into the ODR is more directly?
//test OUT whether cycle output

CodePudding user response:

The ODR is not adjacent, how training in rotation, need to each address into a local team?
I now is to set up good GPIO into an array, and then you can training IN rotation, has achieved the OUT, but found IN wrong ah, IN the access address is wrong, so
 for (I=0; i {
Line_num info_err [I]=I;//to the current line number
* OUTThis [I]=1;//set the line high level * * * * *!!!!!!!!!!! Note here, this OUT mouth can operate

Delay_us (1);

//determine whether conduction
If (1==* INThis [I])//detection circuit conduction
{
Info_err [I] open_err |=0;//conduction, not an error
}
The else
{
Info_err [I] open_err |=1.//an error, the
}

//determine whether with other line short circuit
J=I + 1;
While (j & lt; LINE_NUM_SUM)
{
If (1==* INThis [j])//judge input here, seems to be wrong!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
{
Info_err [I] short_err |=1.
X=PBin (15);
break;
}
J++;
}

Info_err [I] short_err |=0;
* OUTThis [I]=0;//set the line low level
}
  • Related