- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to trigger an interrupt based on the slider switch(GPIO2 on SoCKIT) toggling, but the code below doesn't seem to work. What could be the problem? Also, what is the difference between GPIO2 and ALT_GPIO_PORTB?
# include <stdio.h># include <stdint.h># include <unistd.h># include "hwlib.h"# include "socal/socal.h"# include "socal/hps.h"# include "socal/alt_gpio.h"# include <alt_generalpurpose_io.h># include <sys/time.h># include "alt_interrupt.h"
# define BIT_SW_0 (0x00100000)# define BIT_SW_1 (0x00080000)# define BIT_SW_2 (0x00040000)# define BIT_SW_3 (0x00020000)# define BIT_SW_ALL (BIT_SW_0 | BIT_SW_1 | BIT_SW_2 | BIT_SW_3)
static void alt_gpio_buffer_int_callback()
{
printf("Interrupt Triggered\n");
}
int main(int argc, char** argv) {
uint32_t a;
uint32_t b;
struct timeval t;
unsigned int last_time = 0;
ALT_STATUS_CODE status;
ALT_INT_INTERRUPT_t int_id = 0;
ALT_GPIO_PORT_t gpio_id = ALT_GPIO_PORTB;
alt_setbits_word(ALT_GPIO2_SWPORTA_DDR_ADDR, 0x00000000 );
alt_setbits_word(ALT_GPIO2_INTEN_ADDR, ALT_GPIO_INTEN_GPIO_INTEN_E_EN );
alt_setbits_word(ALT_GPIO2_INTTYPE_LEVEL_ADDR, ALT_GPIO_INTTYPE_LEVEL_GPIO_INTTYPE_LEVEL_E_LEVEL );
alt_setbits_word(ALT_GPIO2_INTMSK_ADDR, ALT_GPIO_INTMSK_GPIO_INTMSK_SET_MSK );
a = (alt_read_word((uint32_t)(ALT_GPIO2_EXT_PORTA_ADDR)) & (uint32_t)(BIT_SW_ALL)) >> 17;
status = alt_gpio_port_int_type_set(gpio_id, 0x1FFFFFFF, 0);
status = alt_gpio_port_int_pol_set(gpio_id, 0x1FFFFFFF, 1);
status = alt_gpio_port_int_enable(gpio_id, 1);
status = alt_gpio_port_int_mask_set(gpio_id, 1, 1);
status = alt_gpio_port_int_status_clear(gpio_id, 1);
status = alt_int_isr_register(int_id, alt_gpio_buffer_int_callback, NULL);
status = alt_int_global_enable();
if (status == ALT_E_SUCCESS)
{
status = alt_int_dist_enable(int_id);
}
while(1){
}
}
Thanks, Patel
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I try run your example in DS-5 debugger, because interesting with interrupts -- with board buttons I not reach result, if enable his -- int request is instantly and persistent.
What documents you read on interrupts theme ? Which examples see ? In attachment picture of debug with return from function alt_int_dist_enable() with error (left ellipse), and ARM processor bit of interrupt enabling is ==1 (right ellipse) -- disabled ! All next travail with buttons will be uselessly, if global interrupt enable bit is disabled. In 2nd picture is status if interrupt pending bit in register CP15.ISR, ==0.
multiple-attachments.zip
(Virus scan in progress ...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi WitFed,
At first, I tried manually setting the interrupt registers, but when that didn't work I using the functions that were being called from the 16550 example. The functions from the 16550 example didn't work either. I wonder what I am doing wrong. Patel- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I recommend get all 16550 project and not cut sources, add your code in position of running, where all from Altera is inited and work.
When your code will be debugged successful, may delete original Alteras lines with small portions, at once recompile and try run in order to your code stay working -- in that way is possible get working small program without exhaustive documentation ! :) For example, 16550 project in main() first call "soc_fpga_init_start()", in which call "alt_int_global_init()", and you -- not !- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Patel, you see page soc design examples (http://www.altera.com/support/examples/soc/soc.html) ?
"GPIO" may be fit for control LEDs with buttons, all work! Only code vilume is very-very big :) Need be installed SoC EDS 14.0, in preceding versions not compiled.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page