Hello ,
I have a buzzer connected to PORTA , Pin 12 on the FRDM KL25Z board. ( GPIOA_PDDR = 0x1000)
I can turn the Buzzer ON and OFF by writing GPIOA_PDOR=0X1000 and GPIOA_PDOR=0 respectively.
However ,I modified the program to GPIOA_PCOR=0x1000 to turn ON the buzzer and GPIOA_PSOR=0X1000 to Turn OFF the Buzzer. The program fails to respond.
Any help is appreciated.
Regards,
Hi,
Use the led demo to test PCOR and PSOR. If it works, your code may have some problem.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Dear Da Li ,
The demo program works fine. Buzzer is connected to PORTA Pin 12. Buzzer works OK if i configure PDOR register as in the program below. However , PCOR and PSOR registers setting to ON and OFF the buzzer does not function.
buzzeroff
LDR R3, =GPIOA_PDOR
LDR R4, =0X0
STR R4, [R3]
B loop
buzzeron
LDR R0, =GPIOA_PDOR
LDR R1, =0x1000
STR R1, [R0]
B loop
To modify the PCOR or PSOR registers, they must be the ones pointed at,
not the Data Output register.
This is from the KL27 that I had at hand:
/** GPIO - Peripheral register structure */
typedef struct GPIO_MemMap {
uint32_t PDOR; /**< Port Data Output Register, offset: 0x0 */
uint32_t PSOR; /**< Port Set Output Register, offset: 0x4 */
uint32_t PCOR; /**< Port Clear Output Register, offset: 0x8 */
uint32_t PTOR; /**< Port Toggle Output Register, offset: 0xC */
uint32_t PDIR; /**< Port Data Input Register, offset: 0x10 */
uint32_t PDDR; /**< Port Data Direction Register, offset: 0x14 */
} volatile *GPIO_MemMapPtr;
Hi,
Why do you use asm? We have the sdk in https://mcuxpresso.nxp.com/en/select.
When you configure the PCOR ans PSOR. Use debugger to check the register if the value is changed.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------