--0-303379256-1080081612=:80151 Content-Type: text/plain; charset=us-ascii Content-Id: Content-Disposition: inline Hi, I just started programming for the PIC18F452 in C, but I know nothing of C. I do know some Visual Basic and PHP and at one time (about a year ago) I was getting advanced in mIRC scripting (resembles PHP a bit). However, my problem is that I've never had to do such 'low level' programming, so a lot of things that are easy on a PC suddenly become difficult for me. Here's my problem: I want to control audio volume with a PGA2310 (TI/BB chip), this is done through an SDI interface. The volume is stored in a 16-bit row, the first byte being the right channel volume and the next 8 bits being the left channel volume. I store the values in a [x][2] array, with x being the number of chips (they can be daisy-chainned, for 5.1 audio volume control for example) and [x][1] being right channel volume, [x][2] being left channel volume. The MSB is send first. My SDI line is on pin 0 of port A. Now, to determine wether SDI should be high or low, I shift the [x][y] byte by k (k starting at 7, going to 0) and AND it with 0b00000001. Then to pull the line low, I AND LATA with 0b11111110, to pull it high, I OR LATA with 0b00000001. Is this the best way, or can I, since I put SDI on pin 0, just say something like: TRISA = (volume[x][y] >> k) & 0b00000001? I'm sorry if this all looks confusing, I'm totally new to this. This is the first project I'm designing all by myself and I fear that I'll need a lot of help, both for hardware and software :). PS: My pga.h file is attached. I'm sure it's full of mistakes, if you find the time, please correct me :). ===== Website: http://members.lycos.nl/anthonyvh __________________________________ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics --0-303379256-1080081612=:80151 Content-Type: application/octet-stream; name="pga.h" Content-Transfer-Encoding: base64 Content-Description: pga.h Content-Disposition: attachment; filename="pga.h" LyoNCioJRnVuY3Rpb25zIGZvciBUSS9CQiBQR0EyMzEwIFN0ZXJlbyBWb2x1 bWUgQ29udHJvbA0KKgkNCioJTWFkZSBieSBBbnRob255IFZhbiBIZXJyZXdl Z2UNCioJRS1tYWlsOiBhbnRob255X3ZfaEB5YWhvby5jb20NCioNCiovDQoN Ci8vIFRvIGFkZDogaW5kaXZpZHVhbCB2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