Do we have to configure a pin as gpio in k70 or we can directly use GPIOx_PDDR for io?
according to XiangJun's direction, you should take the following procedure.
(1) SIM_SCGC5 |= (1<<11); // PORTC Clock Enable(2) PORTC_PCR4 &= ~(7<<7); // set PORTC4 MUX to 000 (disable) PORTC_PCR4 |= (1<<7); // set PORTC4 MUX to 001 (GPIO)(3) GPIOC_PDDR &= ~(1<<4); // set GPIOC4 input
Then, you can get PTC4 input data from GPIOC_PDIR.
Best regards,Yasuhiko Koumoto.
It is dependent on what you use the GPIO pin, if you use the GPIO pin to output signal, this is the procedure:
1)enable the GPIO module clock in the SIM_SCGC5 register, for example, enable PORTA by setting the PORTA bit in SIM_SCGC5
2)configure the MUX bits in PORTx_PCRn register based on the section 10.3.1 K70 Signal Multiplexing and Pin Assignments in reference manual of k70
3)set the corresponding bit in GPIOx_PDDR register to enable GPIO output mode
4)you can set/clear the GPIO pin by writing GPIOx_PDOR.
If you read the logic of the GPIO pin, after you enable the GPIO port clock, I think you can read the pin directly by reading the GPIOx_PTOR register. I think It is okay to set the GPIO pin in GPIO mode by writing the PORTx_PCRn register as above procedure, clear the bit in GPIOx_PDDR register, then read GPIOx_PDIR register to get the pin logic.
Have a nice festival
Hi Xiang I am very new to k70 microcontroller I want to make PTC4 pin as
input to receive digital data fron a device. I have written in this way
GPIOC_PDDR&=(1ul<<4) and then read 4th bit USING GPIOC_PDIR
Is this correct?
On Wed, Dec 24, 2014 at 2:57 PM, xiangjun.rong <
Retrieving data ...