This topic contains 4 replies, has 3 voices, and was last updated by VS Eschholz 4 years, 4 months ago.
-
AuthorPosts
-
April 24, 2019 at 3:04 pm #398
Hello,
Based on the example gpio_input_interrupt (found in the folder driver_examples of the SDK) I`ve been trying to add another switch from the board in order to make an simple code where one switch is responsible for turning the LED on and the other for tuning it off. Even after making the necessary changes I have always a problem with the execution of the function GPIO_PinInit().
I’ve tried first with the cortex ARM-M4, making the following adjusts:
– in pin_mux.c, BOARD_InitPins() : add CLOCK_EnableClock(kCLOCK_PortE);
– in pin_mux.c, BOARD_InitPins() : add PORT_SetPinConfig(PORTE, PIN8_IDX, &porte8_pinP16_config);
– in board.h : add the definitions necessaries for SW3;
– in gpio_input_interrupt : add IRF named PORTE_IRQHandler();
– in gpio_input_interrupt, main() : add PORT_SetPinInterruptConfig(PORTE, PIN8_IDX, kPORT_InterruptFallingEdge);
add EnableIRQ(PORTE_IRQn);
add GPIO_PinInit(GPIOE, PIN8_IDX, &sw_config).Trying to run the program, I`ve got the following:
Breakpoint 1, main ()
122 GPIO_PinInit(GPIOE, PIN8_IDX, &sw_config).
(gdb) s
GPIO_PinInit (base=0x4100f000, pin=8, config=0x2002fff0)
66 assert(config);
(gdb) n
68 if (config->pinDirection == kGPIO_DigitalInput)
(gdb) n
70 base->PDDR &= ~(1U << pin);
(gdb) n
HardFault_Handler () at C:\Vega\rv32m1_sdk_arm\devices\RV32M1\gcc\startup_RV32M1_cm4.S:398
398 ldr r0,=HardFault_HandlerI`ve also tried with ARM-M0+ with necessary changes, but the same error remains. In the cores RISCV, the error is in the same function, but is given like that:
GPIO_PinInit (base=0x4100f000, pin=8, config=0x9000c28)
66 assert(config);
(gdb) n
68 if (config->pinDirection == kGPIO_DigitalInput)
(gdb) n
70 base->PDDR &= ~(1U << pin);
(gdb) n
__VECTOR_TABLE () at C:\Vega\rv32m1_sdk_riscv\devices\RV32M1\gcc\startup_RV32M1_zero_riscy.S:75
75 jal x0, LSU_Handler
(gdb) n
Program stopped.
207 define_exception_entry LSU_Handler LSU_HandlerFuncAnyone who has already used SW3, SW4 or SW5 in a VegaBoard application with any core could give me a hand ?
Thank you,
Vitor.April 29, 2019 at 3:22 pm #400Hi VS Eschholz,
It seems like you are forgetting to set the pin as GPIO. Please add this line before calling GPIO_PinInit
PORT_SetPinMux(PORTE, 16, kPORT_MuxAsGpio);
April 30, 2019 at 6:45 am #402Hello Alex,
Thank you for your answer. In fact, in order to configure the pin as GPIO I`m using the function PORT_SetPinConfig() in pin_mux.c whit the following struct :
const port_pin_config_t porte8_pinP16_config = {
kPORT_PullUp,
kPORT_FastSlewRate,
kPORT_PassiveFilterDisable,
kPORT_OpenDrainDisable,
kPORT_LowDriveStrength,
kPORT_MuxAsGpio,
kPORT_UnlockRegister
};
PORT_SetPinConfig(PORTE, PIN9_IDX, &porte8_pinP16_config);I`ve already tried to use PORT_SetPinMux(PORTE, 9, kPORT_MuxAsGpio), but still have the same problem.
May 10, 2019 at 1:02 am #418Hi VS Eschholz,
Please call CLOCK_EnableClock(kCLOCK_Rgpio1); this enables the clock for GPIOE.
Thanks.
May 10, 2019 at 8:18 am #419Hi Jason_Yu,
I had not noticed that for the GPIOE the registers are also aliased to the IOPORT interface through FGPIOE. Retesting it calling CLOCK_EnableClock(kCLOCK_Rgpio1) solved the problem.
Thank you!
-
AuthorPosts
You must be logged in to reply to this topic. Login here