CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

beginner question on interrupt ***Locked- C30/XC16 off topic

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
littlewhitedot



Joined: 27 Nov 2016
Posts: 5

View user's profile Send private message

beginner question on interrupt ***Locked- C30/XC16 off topic
PostPosted: Sun Jan 08, 2017 8:44 am     Reply with quote

+++++++++++++++++++++
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: 19497

View user's profile Send private message

PostPosted: Sun Jan 08, 2017 9:16 am     Reply with quote

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: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jan 08, 2017 10:08 am     Reply with quote

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
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group