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

10 bit DAC Port definition

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tonofit



Joined: 23 Jun 2005
Posts: 4

View user's profile Send private message

10 bit DAC Port definition
PostPosted: Thu Jul 21, 2005 7:02 pm     Reply with quote

I'm working with a PIC18F722. The following I/O pins are used:
Pin H3 MSB
Pin H2
Pins J7-J0, with J0 the LSB

How do I pick a PORT Address to read/write values to the DAC?

How do I read/write the data to the DAC using a PORT HJ definition as one write of 10 bits?

I tried using the definition in the F18722.h file and making the PORT HJ use the F18722.h H3 pin since it was the MSB. That is not correct.

I guess I need to use a valid RAM address that will point to the definition of PORT. Is that right?

Code:
#define PORTHJ_BASE      31801
#define PORTHJ           ((unsigned int*) PORTHJ_BASE)

typedef struct PortHJStruct
{
    unsigned int HJ0  :1;
    unsigned int HJ1  :1;
    unsigned int HJ2  :1;
    unsigned int HJ3  :1;
    unsigned int HJ4  :1;
    unsigned int HJ5  :1;
    unsigned int HJ6  :1;
    unsigned int HJ7  :1;
    unsigned int HJ8  :1;
    unsigned int HJ9  :1;
} PORTHJ_STRUCT;

PORTHJ_STRUCT PortHJbits;
#locate PortHJbits = PORTHJ_BASE


The F18722.h file has an address definition of PIN_H1 of 31801

When I try to compile the code I get the following error message

*** Error 103 "C:\PROGRA~1\PICC\drivers\string.h" Line 34(1,2): Constant out of the valid range 7C3A is out of the RAM range
*** Error 43 "C:\PROGRA~1\PICC\drivers\string.h" Line 34(6,7): Expecting a declaration
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 21, 2005 7:52 pm     Reply with quote

Your code is incorrect in several ways. First post the manufacturer
and part number of the DAC chip that you're using. After we look
at the data sheet, then we can decide the best way to do it.
Guest








PostPosted: Fri Jul 22, 2005 10:38 am     Reply with quote

The DAC is from Analog Devices AD5583 Quad parallel input 12/10 bit
URL: http://www.analog.com/UploadedFiles/Data_Sheets/32975162110307AD5582_83_a.pdf
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jul 23, 2005 12:18 am     Reply with quote

Quote:
I'm working with a PIC18F722.

I think you mean the 18F8722.

The test program shown below produces the following ASM code.
I think this is what you want.
Code:
.................... PortHJ.dac_data = 0x234; 
0014:  MOVLW  02
0016:  MOVWF  F88
0018:  MOVLW  34
001A:  MOVWF  F87
....................   


My version of PCH (3.188) doesn't support the 18F8722, so I compiled it
for the 18F8720, which also has ports H and J:
Code:
#include <18F8720.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP   
#use delay(clock=4000000)

union
{
struct
  {
   int8 PortH;
   int8 PortJ : 2;
   int8 unused: 6;
  }PortHJ_bits;
int16 dac_data;
}PORTHJ;

#locate PortHJ = 0xF87     // Port H (0xF87) is the base address

void main()
{
   
PortHJ.dac_data = 0x234;

while(1);
}
Display posts from previous:   
Post new topic   Reply to topic    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