Jump to content

ACSim and ADCON1 declaration?


ilmenator
 Share

Recommended Posts

Hi all,

after getting Code::Blocks to work properly with ACSim I ran into the next problem.

I'm using Port A to interface to some SRAM memory, so I need to disable the ADC and set up the port properly. This is the init function I use:

void SRAM_Init(void) __wparam
{
	// disable the ADC which allocates the analog pins
	// only needed if controls pins are connected to port A
	ADCON1 = 0x07;

	// put PortA in output mode
	TRISAbits.TRISA0 = 0;
	TRISAbits.TRISA1 = 0;
	TRISAbits.TRISA2 = 0;
	TRISAbits.TRISA3 = 0;
	TRISAbits.TRISA5 = 0;

	// set control lines
	PORTAbits.RA5 = 1;
	PORTAbits.RA3 = 1;
	PORTAbits.RA2 = 1;
	PORTAbits.RA0 = 0;
	PORTAbits.RA1 = 0;

	// configure RD4 as input for reading SRAM card status
	TRISDbits.TRISD4 = 1;

	return;
}
The code compiles fine for the RELEASE target. For the DEBUG target it gives me
error: 'ADCON1' undeclared (first use in this function)

and naturally the same for TRISAbits, PORTAbits, etc.

I suspect that this is related to something that ACSim would need to know about but does not yet? How would I add this information to make the code compile in DEBUG mode?

Best regards, ilmenator

Link to comment
Share on other sites

Hi,

these special parts aren't yet defined in ACSim, I concentrated on the basic MIOS functions, but you can add them manually; there are already some PORTCbits and PORTDbits, so you'll know where to paste it:

please add this to ACSim_mios.h:

// "pic18f452.h" typedefs
typedef union {
	struct {
		unsigned PCFG0:1;
		unsigned PCFG1:1;
		unsigned PCFG2:1;
		unsigned PCFG3:1;
		unsigned :1;
		unsigned :1;
		unsigned ADCS2:1;
		unsigned ADFM:1;
	};
} __ADCON1bits_t;

typedef union {
	struct {
		unsigned TRISA0:1;
		unsigned TRISA1:1;
		unsigned TRISA2:1;
		unsigned TRISA3:1;
		unsigned TRISA4:1;
		unsigned TRISA5:1;
		unsigned TRISA6:1;
		unsigned :1;
	};
} __TRISAbits_t;

typedef union {
	struct {
		unsigned RA0:1;
		unsigned RA1:1;
		unsigned RA2:1;
		unsigned RA3:1;
		unsigned RA4:1;
		unsigned RA5:1;
		unsigned RA6:1;
		unsigned :1;
	};
	struct {
		unsigned AN0:1;
		unsigned AN1:1;
		unsigned AN2:1;
		unsigned AN3:1;
		unsigned :1;
		unsigned AN4:1;
		unsigned OSC2:1;
		unsigned :1;
	};
	struct {
		unsigned :1;
		unsigned :1;
		unsigned VREFM:1;
		unsigned VREFP:1;
		unsigned T0CKI:1;
		unsigned SS:1;
		unsigned CLK0:1;
		unsigned :1;
	};
	struct {
		unsigned :1;
		unsigned :1;
		unsigned :1;
		unsigned :1;
		unsigned :1;
		unsigned LVDIN:1;
		unsigned :1;
		unsigned :1;
	};
} __PORTAbits_t;
and this to ACSim_mios.c:
// "pic18f452.h" 
__ADCON1bits_t ADCON1bits;
__TRISAbits_t TRISAbits;
__PORTAbits_t PORTAbits;

basically, the typedefs are just copied from pic18f452.h and pasted to ACSim_mios.h. And a variable in ACSim_mios.c is instantiated.

I know this is probably a bit messy, but all this pic18fxxx.h/.c stuff needs a clean up anyway, so in order to get it running... :-\

Best,

Michael

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...