Thread: dsPIC33 compiler errors.........

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    9

    dsPIC33 compiler errors.........

    Hi, Trying to build come simple code to o/p a 50Hz sine wave from LUT but cant get rid of the last few compiler errors and wondered if anyone could help at all....

    Target device is a dsPEC33FJ256MC710

    MOD FESS Main.c:97: warning: type defaults to 'int' in declaration of 'PTCON'
    MOD FESS Main.c:97: error: conflicting type qualifiers for 'PTCON'
    c:/program files/microchip/mplab c30/bin/bin/../../support/dsPIC33F/h/p33FJ256MC710.h:1713: error: previous declaration of 'PTCON' was here
    MOD FESS Main.c:97: warning: data definition has no type or storage class
    MOD FESS Main.c:103: warning: type defaults to 'int' in declaration of 'PTPER'
    MOD FESS Main.c:103: error: conflicting type qualifiers for 'PTPER'
    c:/program files/microchip/mplab c30/bin/bin/../../support/dsPIC33F/h/p33FJ256MC710.h:1759: error: previous declaration of 'PTPER' was here
    MOD FESS Main.c:103: warning: data definition has no type or storage class
    MOD FESS Main.c:111: error: syntax error before '.' token
    MOD FESS Main.c:130: warning: type defaults to 'int' in declaration of 'PTMR'
    MOD FESS Main.c:130: error: conflicting type qualifiers for 'PTMR'
    c:/program files/microchip/mplab c30/bin/bin/../../support/dsPIC33F/h/p33FJ256MC710.h:1746: error: previous declaration of 'PTMR' was here
    MOD FESS Main.c:130: warning: data definition has no type or storage class
    MOD FESS Main.c:132: error: syntax error before '.' token
    MOD FESS Main.c:134: warning: type defaults to 'int' in declaration of 'PDTCON1'
    MOD FESS Main.c:134: warning: data definition has no type or storage class
    MOD FESS Main.c:135: warning: type defaults to 'int' in declaration of 'PDTCON2'
    MOD FESS Main.c:135: warning: data definition has no type or storage class
    MOD FESS Main.c:136: warning: type defaults to 'int' in declaration of 'POVDCON'
    MOD FESS Main.c:136: warning: data definition has no type or storage class
    MOD FESS Main.c:138: warning: type defaults to 'int' in declaration of 'PFLTACON'
    MOD FESS Main.c:138: warning: data definition has no type or storage class
    MOD FESS Main.c:139: warning: type defaults to 'int' in declaration of 'PFLTBCON'
    MOD FESS Main.c:139: warning: data definition has no type or storage class
    MOD FESS Main.c:149: error: syntax error before 'while'
    MOD FESS Main.c:156: warning: type defaults to 'int' in declaration of 'PDC1'
    MOD FESS Main.c:156: error: conflicting type qualifiers for 'PDC1'
    c:/program files/microchip/mplab c30/bin/bin/../../support/dsPIC33F/h/p33FJ256MC710.h:2062: error: previous declaration of 'PDC1' was here
    MOD FESS Main.c:156: warning: data definition has no type or storage class
    MOD FESS Main.c:156: error: syntax error before '=' token
    MOD FESS Main.c:167:2: error: #endif without #if

    Any help would be most appreciated....
    Thanks
    Attached Files Attached Files

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    All that code from line 97 to line 139 is outside of any function. Presumably you intended it to be inside some function.

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    9
    Hi, These are just the definitions for the pwm registers for that particular PIC. Dont think they need to be inside a function as they just get read once when the code executes...
    Cheers

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by yan_c View Post
    Hi, These are just the definitions for the pwm registers for that particular PIC. Dont think they need to be inside a function as they just get read once when the code executes...
    Cheers
    You are wrong; code not inside of functions are not executed!!

    Edit: Variables can NOT be assigned a new value except in executable code (code inside a function).

    Tim S.

  5. #5
    Registered User
    Join Date
    Jun 2011
    Posts
    9
    ok I'll take a look at this.......
    Thanks all for the comments

  6. #6
    Registered User
    Join Date
    Jun 2011
    Posts
    9
    Tried including the PWM reg definitions in main but still get the same errors...
    Attached Files Attached Files

  7. #7
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    That's a really bad attempt at trying to get one past us, what with the code proving the lie. All that code starting at line 97 is not in a function. Don't do that.

    In fact you don't even have a legal main function at all -- you need to start with your main declaration, then open a squiggle, then put all your code in, then close it off with a squiggle. You've got the word "main" in your code at line 147, you just need to actually do the rest of it.

  8. #8
    Registered User
    Join Date
    Jun 2011
    Posts
    9
    Hi, not trying to test you at all, Im just learning C so just need a little help to get the basics right. Not quite sure what you mean. Can you mod my code to show me what you mean exactly...?
    Thanks

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    What main should look like (we'll let you keep your void main for now):
    Code:
    void main() 
    {
    /* Always nice to start things */
    
    /* Put all your code here, not strewn randomly about like rose petals */
    
    }
    /* Always nice to stop things */

  10. #10
    Registered User
    Join Date
    Jun 2011
    Posts
    9
    Many thanks for your help. Managed to get it to compile with just one warning, so a big step forward........!!

    Just need to get it to do what I want now, so I might be back needing a bit more advice.

    Thanks again to all.......

  11. #11
    Awesomefaceradcore bivhitscar's Avatar
    Join Date
    Apr 2006
    Location
    Melbourne, Australia
    Posts
    210
    Quote Originally Posted by tabstop View Post
    (we'll let you keep your void main for now)
    Given that this is a microcontroller, it's pretty common to declare the return type as void - because if your main ever actually returns you've made a mistake and there's no one there listening.
    it's ironic considerate rarity patron of love higher knowledge engulfs me...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. More Compiler Errors...
    By P3nGu1N in forum C Programming
    Replies: 11
    Last Post: 03-13-2009, 10:38 AM
  2. Compiler errors
    By Beowolf in forum C++ Programming
    Replies: 12
    Last Post: 10-31-2007, 09:25 AM
  3. Compiler errors
    By ICool in forum C Programming
    Replies: 9
    Last Post: 10-18-2007, 08:01 AM
  4. Compiler errors
    By JaWiB in forum Windows Programming
    Replies: 3
    Last Post: 03-02-2003, 01:28 AM
  5. Compiler errors
    By BellosX in forum C Programming
    Replies: 2
    Last Post: 09-21-2001, 03:24 AM