Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Questions about MPLAC-C30 Compiler

Status
Not open for further replies.

Regnum

Full Member level 5
Joined
Jun 17, 2004
Messages
262
Helped
18
Reputation
36
Reaction score
7
Trophy points
1,298
Location
Hurlingham
Activity points
2,168
microchip pic c30 stdout on uart

In MPLAB-C30 (C compiler for Microchip dsPIC30 Family)

1) How do I declare boolean variables ?
2) How do I redirect stdout to the second UART ?

Thanks,
Regnum
 

int 8 c30 compiler

Q1:
#define true 1
#define false 0
#define TRUE 1
#define FALSE 0

typedef unsigned short boolean


//using it

boolean FLAG=false;

FLAG=true;
 

    Regnum

    Points: 2
    Helpful Answer Positive Rating
microchip c30 boolean variables

To Regnum:
Look for 'union' in Microchip forum, you should find some good example about using bit fields in a union.

I missed you 2nd question. Have a look at this thread on Microchip forum:
http://forum.microchip.com/tm.aspx?m=176397

To PaulHolland:
You are wasting one unsigned short for every bit.

Cheers,
 

    Regnum

    Points: 2
    Helpful Answer Positive Rating
c30 32bit union

To namqn:

I know you use a 16 bits or a byte (8) for every bit (logical) but I don't know what the guy needs. Your union is only usefull if you define funtions to bits but his question was : How do you do boolean. and I told him how to delare a new type !.

A union or structure is only usefull if you have different bits and give them a function, you need to address them yourself and the compiler is NOT arranging them for you !
If code efficiency is the most important thing you should program in asm and forget C, C can be nice but no way it can beat my asm code !. AES128 encryption in 380 bytes (asm) on a 12F series pic you can forget in C

regards,

Paul.
 

microchip c30 compiler

MISRA recomends that you should use typedef for sizes and the posix types.

Code:
/*********************************************************************
* File Name     : types.h 
* Description   : Posix Typedef file.                      

* Revision      : 1.0 
* Date          : 21/08/05 
*********************************************************************/

#ifndef TYPES_H
#define TYPES_H
            
/*--- Standard type definitions. ---*/

typedef unsigned char  uint8_t;   /* unsigned 8 bit type definition */
typedef signed char	  int8_t;   /* signed 8 bit type definition */
typedef unsigned int  uint16_t;	/* unsigned 16 bit type definition */
typedef signed int	  int16_t;   /* signed 16 bit type definition */
typedef unsigned long uint32_t;	/* unsigned 32 bit type definition */
typedef signed long	 int32_t;   /* signed 32 bit type definition */
typedef unsigned int      Bool;   /* Bool type definition */

#endif

/*--- Standard constant definition. ---*/

#define False ((uint16_t)0x0000)
#define True  ((uint16_t)0x0001)

/*--- End of file. ---*/

Added after 6 minutes:

The Pic30_tools from Microchip is a port of the GCC compiler which is one bad ass compiler.
I think you'll find that printf() calls putch() for output.
You can write your own putch() function to output to UART2 or CAN or SPI or I2C or whatever.

Added after 2 minutes:
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top