Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Enable Port J&N clock control]
- # define SYSCTL_RCGCGPIO_R (*((volatile unsigned long *) 0x400FE608))
- # define SYSCTL_RCGCGPIO_GPIOJN 0x00001100
- // GPIO Port N, pin 1
- # define GPIO_PORTN_DIR_R (*((volatile unsigned long *) 0x40064400))
- # define GPIO_PORTN_DEN_R (*((volatile unsigned long *) 0x4006451C))
- # define GPIO_PORTN_DATA_WR (*((volatile unsigned long *) 0x40064008)) // Bit-Specific For Pin 1
- // GPIO Port J, pin 0 (Pin 1 from template)
- # define GPIO_PORTJ_DIR_R (*((volatile unsigned long *) 0x40060400))
- # define GPIO_PORTJ_DEN_R (*((volatile unsigned long *) 0x4006051C))
- # define GPIO_PORTJ_PUR_R (*((volatile unsigned long *) 0x40060510)) // Input
- # define GPIO_PORTJ_DATA_RD (*((volatile unsigned long *) 0x40060004)) // Input_ Bit Specific for Pin 0
- // Port pin definitions
- # define GPIO_PORTJ_PIN0 0x01
- # define GPIO_PORTN_PIN1 0x02
- // Default clock frequency and delay definition
- # define SYSTEM_CLOCK_FREQUENCY 16000000
- # define DELAY_VALUE SYSTEM_CLOCK_FREQUENCY/1000
- // IRQ 32 to 63 Set Enable Register
- # define NVIC_EN1_R (*((volatile unsigned long *) 0xE000E104)) // NVIC Interrupt Enable (32-63) (0x104)
- // NVIC interrupt enable configuration constant for Interrupt #51
- # define NVIC_EN1_INT51 0x00010000 // ??
- // IRQ 48 to 51 Priority Register
- # define NVIC_PRI12_R (*((volatile unsigned long *) 0xE000E430)) // NVIC Interrupt Priority (0x430)
- // GPIO Port J Interrupt Configuration
- # define GPIO_PORTJ_IS_R (*((volatile unsigned long *) 0x40060404)) // GPIO Interrupt Sense (0x404)
- # define GPIO_PORTJ_IBE_R (*((volatile unsigned long *) 0x40060408)) // GPIO Interrupt Both Edges (0x408)
- # define GPIO_PORTJ_IEV_R (*((volatile unsigned long *) 0x4006040C)) // GPIO Interrupt Event (0x40C)
- # define GPIO_PORTJ_IM_R (*((volatile unsigned long *) 0x40060410)) // GPIO Interrupt Mask (0x410)
- # define GPIO_PORTJ_ICR_R (*((volatile unsigned long *) 0x4006041C)) // GPIO Interrupt Clear (0x41C)
- // Function prototypes
- volatile unsigned char SW2;
- void Delay ( unsigned long counter );
- void GPIOJ_Handler ( void );
- // user main program
- int main()
- {
- // Enable the clock for port J and N (Combined together from template given)
- SYSCTL_RCGCGPIO_R |= SYSCTL_RCGCGPIO_GPIOJN;
- // Enable Ports J and N
- GPIO_PORTJ_DEN_R |= GPIO_PORTJ_PIN0 ;
- GPIO_PORTN_DEN_R |= GPIO_PORTN_PIN1 ;
- // Set Pull-Up Resistor for Port J ONLY (Pin 0 = 0x01)
- GPIO_PORTJ_PUR_R |= 0x01;
- // Set Port N Pin 1 as an Output
- GPIO_PORTN_DIR_R |= (GPIO_PORTN_PIN1);
- // Interrupt Register Settings
- GPIO_PORTJ_IS_R &= ~0x10; // Port J is edge-sensitive
- GPIO_PORTJ_IBE_R &= ~0x10; // Port J is not both edge sensitive
- GPIO_PORTJ_IEV_R &= ~0x10; // Port J responds to a falling edge event
- GPIO_PORTJ_IM_R |= 0x10; // Enable Interrupt on Port J
- GPIO_PORTJ_ICR_R = 0x10; // Clear Port J
- while(1) {
- }
- }
- // Interrupt service routine for Port J
- void GPIOJ_Handler ( void )
- {
- GPIO_PORTJ_ICR_R = 0x10;
- SW2 = 1;
- }
- // Function Delay implements the delay
- void Delay ( unsigned long counter )
- {
- unsigned long i = 0;
- for (i =0; i < counter ; i ++) ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement