Command for pcm1738

Hello everyone.
I'm new to the forum, I have this problem, this BB PCM1738 audio converter requires a command to work, by default it is set to 16bit "FMT 000", I would like to be able to use the other settings too so I thought about using Arduino to send the commands but I didn't I know how to do it.

Anyone have any ideas on this?

I found some info online but programmed in C so I would like to use Arduino nano and create the program.

That is the suggestion:

/* defines */

#define F_CPU 1200000 /* for ATtiny13, running at 1.2MHz */

#define DATAPORT PORTB
#define DATAPINS PINB
#define CSPIN 2 /* PB2 (Pin#7) /
#define MCPIN 1 /
PB1 (Pin#6) /
#define MDIPIN 0 /
PB0 (Pin#5) */

/* macros */

#define CS_low() DATAPORT &= ~_BV(CSPIN)
#define CS_high() DATAPORT |= _BV(CSPIN)
#define MDI_low() DATAPORT &= ~_BV(MDIPIN)
#define MDI_high() DATAPORT |= _BV(MDIPIN)
#define MC_tick() { DATAPORT |= _BV(MCPIN); _delay_us(1); DATAPORT &= ~_BV(MCPIN); }

#include <avr/io.h>
#include <util/delay.h>

void write_register(uint8_t reg, uint8_t value)
{
uint16_t word= (reg << 8) | value;

CS_low();
for (uint8_t i=0; i<16; i++)
{
if (word & 0x80)
MDI_high();
else
MDI_low();
MC_tick();
word <<= 1;
}
CS_high();
}

int main(void)
{
/* hardware init*/
/* all pins input, except CS, MC, MDI /
DATAPINS=(_BV(CSPIN)|_BV(MCPIN)|_BV(MDIPIN));
/
all pins H (pullups enabled), except MC */
DATAPORT=~_BV(MCPIN);

/* write DAC register(s) */
write_register(18, 0x50);

/* endless loop */
while (1) ;
}

I moved your topic to an appropriate forum category @sergioby.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Ok thaks, I apologize.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.