View previous topic :: View next topic |
Author |
Message |
littlewhitedot
Joined: 27 Nov 2016 Posts: 5
|
beginner question on interrupt ***Locked- C30/XC16 off topic |
Posted: Sun Jan 08, 2017 8:44 am |
|
|
+++++++++++++++++++++
Locked.
Reason: Microchip C30 and XC16 compilers are off-topic on CCS forum.
Use the Microchip PIC24 Topics forum:
http://www.microchip.com/forums/f179.aspx
- Forum Moderator
+++++++++++++++++++++
Hi all, i am using pic24fjgb002. I am trying out a simple interrupt code here but it does not seem to work.
Code: |
#include "config.h"
void timer1_init(){
//timer1 on, prescaler=64 (1Hz), select internal osc
uint16_t mask = 0x8032;
T1CON = (T1CON & ~mask)|(0x8020 & mask);
}
void interrupt_init(){
INTCON1bits.NSTDIS = 1; //disable nesting interrupt
_T1IP = 0b001; //timer1 priority 001
_T1IE = 1; //enable timer1 interrupt
IFS0bits.T1IF = 0; //reset timer1 interrupt flag
}
int main(void) {
interrupt_init();
timer1_init();
TRISAbits.TRISA0 = 0; //A0 as output
while(1){
}
}
void __attribute__((interrupt(auto_psv))) timer1_isr(void){
if(IFS0bits.T1IF == 1){ //if timer1 flag = 1
LATAbits.LATA0 ^= 1;
IFS0bits.T1IF = 0; //reset timer1 flag bit
}
}
|
For interrupt function, previously I have also try void interrupt timer1_isr, but it does not work. Can anyone help me out please? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Sun Jan 08, 2017 9:16 am |
|
|
Have you read the header of this forum?.
This forum is for _CCS C_.
Your code is not CCS C..... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Sun Jan 08, 2017 10:08 am |
|
|
Just 30 seconds LOOKING at that convuluted,confusing code made me soooo happy I chose CCS 25 years ago !
aside from no processor include those double underscored names scare me.
The CCS C equal of what is shown is clear, clean and EASY to understand !
Jay |
|
|
|