ΣSigmaStudio Ask AI Русский Log in

ADSP BF 548 SPI Slave register accessing issue

Processors & DSP amar26121993 Jan 9, 2018 00:00 4 replies Original on forum ↗
Subscribe
amar26121993 Question
Jan 9, 2018 00:00

Hi,

Iam using ADZS BF 548 Eval board in my project. iam using Visual DSP++ 5.1.2 trail version.

I am working to access a Slave Device through SPI interface, basic access involves write and read Registers of the slave device.

when i try to access the slave device by writting register level (SPI Registers of BF548) access code and perform write and read with slave device.

access to the slave device is working fine. the complete code was written in main functions. below is portion of code which is working

//----------Reg Write-------------------

RegAddress=0x01;

Reg_data1[0]=0x00;

Reg_data1[1]=0x00;

*pPORTB_CLEAR = PB9;

SPI_Write((0x80|RegAddress));

SPI_Write(Reg_data1[0]);

SPI_Write(Reg_data1[1]);

*pPORTB_SET = PB9;

//--------------------------------------------

RegAddress=0x0F;

Reg_data1[0]=0xFC;

Reg_data1[1]=0xC0;

*pPORTB_CLEAR = PB9;

SPI_Write((0x80|RegAddress));

SPI_Write(Reg_data1[0]);

SPI_Write(Reg_data1[1]);

*pPORTB_SET = PB9;

//--------------------------------------------

RegAddress=0x11;

Reg_data1[0]=0x12;

Reg_data1[1]=0xCD;

*pPORTB_CLEAR = PB9;

SPI_Write((0x80|RegAddress));

SPI_Write(Reg_data1[0]);

SPI_Write(Reg_data1[1]);

*pPORTB_SET = PB9;

while(1)// reading registers in while loop

{

RegAddress=0x00;

//--------------------------------------

*pPORTB_CLEAR = PB9;

HI_6136_Cmdtx(0x00|(RegAddress<<2));

Readvalue1=SPI_Read();

Readvalue2=SPI_Read();

*pPORTB_SET = PB9;

dataAcq =((Readvalue1<<8)|Readvalue2);

printf("%04x\t",dataAcq);

*pPORTB_CLEAR = PB9;

write_Mapreg(0x0b,0x0011);

*pPORTB_SET = PB9;

*pPORTB_CLEAR = PB9;

HI_6136_Cmdtx(0x40);

Readvalue1=SPI_Read();

Readvalue2=SPI_Read();

*pPORTB_SET = PB9;

dataAcq =((Readvalue1<<8)|Readvalue2);

printf("%04x\t",dataAcq);

//--------------------------------------

*pPORTB_CLEAR = PB9;

write_Mapreg(0x0b,0x0019);

*pPORTB_SET = PB9;

*pPORTB_CLEAR = PB9;

HI_6136_Cmdtx(0x40);

Readvalue1=SPI_Read();

Readvalue2=SPI_Read();

*pPORTB_SET = PB9;

dataAcq =((Readvalue1<<8)|Readvalue2);

printf("%04x\t",dataAcq);

//--------------------------------------

*pPORTB_CLEAR = PB9;

write_Mapreg(0x0b,0x001C);

*pPORTB_SET = PB9;

*pPORTB_CLEAR = PB9;

HI_6136_Cmdtx(0x40);

Readvalue1=SPI_Read();

Readvalue2=SPI_Read();

*pPORTB_SET = PB9;

dataAcq =((Readvalue1<<8)|Readvalue2);

printf("%04x\t",dataAcq);

Readvalue1=Readvalue2=0;

//-------------------------------------

when i replaced the write and read code from main function to a separate function and called those read and write functions in the main function,

the access to slave device is not working and always i am reading 0x0000/0xFFFF. only change to working and not working is read and write was made

as separate functions. below is the protion of code which is not working

WriteRegister(0,0x00,0xC050);

WriteRegister(0,0x00,0xC050);

WriteRegister(0,0x01,0x0000);

WriteRegister(0,0xF,0xFCC0);

WriteRegister(0,0x11,0xABCD);

WriteRegister(0,0x1C,0x2468);

WriteRegister(0,0x1D,0x1359);

while(1)// reading registers in while loop

{

dataAcq= ReadRegister(0,0x0000);

printf("%x\t",dataAcq);

dataAcq = ReadRegister(0,0x0001);

printf("%x\t",dataAcq);

dataAcq = ReadRegister(0,0x000F);

printf("%x\t",dataAcq);

dataAcq = ReadRegister(0,0x0011);

printf("%x\t",dataAcq);

dataAcq = ReadRegister(0,0x001C);

printf("%x\t",dataAcq);

dataAcq = ReadRegister(0,0x001D);

printf("%x\t",dataAcq);

also i found one more issue in the working code (i.e. access code written in main function), In between in the code(main.c) if a unwanted function is commented

and run code the access is giving a intermadiate error in read with reading 0x0000/0xFFFF in between. the function which are effecting defined above main function.

"write_low_reg_1(U8BIT a1, U16BIT a2)" and "SPI_READ_HOLT(unsigned short a3)" .

Does the function overhead making any issue?

please find the attached two files main.c and board_613x.c

SPI configuration

word length - 8 bit

data transfer - MSB sent first

SPI Clk - 22.2Mhz

SPI Mode - 0

kindly give your suggestion and suggest if any changes to be done.

thanks for your reply in advance.

Best regards

Amar TR

Software Engineer

SLN Technologies

blackfin

jobo23 Reply
Jan 12, 2018 00:00

Did you forget to attach the main.c?

amar26121993 Reply
Jan 13, 2018 00:00

Dear sir

Main .c file is been attached

Best regards

Amar TR

ADIApproved Reply
Jan 19, 2018 00:00

You missed to attache the main.c file.

EZAdministrator Reply
Aug 2, 2018 00:00

This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

Thank you,
EZ Admin