PDA

View Full Version : Control BH1415 with a 16f88



savnik
- 7th July 2007, 10:53
Until today i have use the pic16f88 to control a TSA 5511.
My problem now is how to control a BH1415 with pic16f88, because this chip has data - clock and enable.
I have found code , but is for C ,and i don't now.



int setFreq[] = {1,0,1,1,1,1,1,1,1,1,0,1,0,0,1,0};
// set the frequency to 102.1 MHz and other config bits for audio IC
// write_to_chip - write enable, clock, and data bits to audio IC
void write_to_chip(){
int i,j;
PBOUT |= 0x01;
for(j = 0; j <= 10; j++) // set a clock delay
asm("nop");
for(i = 0; i < 16; i++){
if(setFreq[i] == 1)
PBOUT |= 0x04; // set data bit
else PBOUT &= 0xFB;
for(j = 0; j <= 10; j++) // set clock down delay
asm("nop");
PBOUT |= 0x02; // turn clock on
for(j = 0; j <= 10; j++) // set up clock delay
asm("nop");
PBOUT &= 0xFD; // turn clock off
}
PBOUT &= 0xFE;
}

bbarney
- 7th July 2007, 12:08
this should help you convert it even though it is for converting c to proton you should still get the idea

Bruce
- 7th July 2007, 19:13
Try this;

i var byte
j var byte
setfreq var byte
PBOUT var PORTB ' my assumption here. have no idea what PBOUT is.
TRISB = 0 ' not sure if this is what you need, but..

Main:
gosub write_to_chip
goto Main

write_to_chip:
PBOUT = PBOUT | 1

for j = 0 to 10
@ nop
next j

for i = 0 to 15
lookup i,[1,0,1,1,1,1,1,1,1,1,0,1,0,0,1,0],setfreq

if setfreq = 1 then
PBOUT = PBOUT | 4
else
PBOUT = PBOUT & $FB
endif

for j = 0 to 10
@ nop
next j

PBOUT = PBOUT | 0x02;

for j = 0 to 10
@ nop
next j

PBOUT = PBOUT & $FD
next i

PBOUT = PBOUT & $FE
RETURN
You could probably replace the j loops & nops with pauseus x if you knew the
time delay required for x.

savnik
- 7th July 2007, 19:39
This code is from this : http://people.msoe.edu/~mohre/FinalReport.pdf
and page 17
Anyone know how to control this chip (BH1415) ;

skimask
- 7th July 2007, 19:52
This code is from this : http://people.msoe.edu/~mohre/FinalReport.pdf
and page 17
Anyone know how to control this chip (BH1415) ;

Do you not have the bh1415f datasheet?
It explains how to set the frequency in there...all easily done with PBP's SHIFTOUT commands...

bits 0 - 15
1,0,1,1,1,1,1,1,1,1,0,1,0,0,1,0

bits 0-10 = frequency, in this case 102.1Mhz
bit 11 = mode, in this case stereo
bits 12-13 = phase detector operation, in this case normal
bits 14-15 = test mode, in this case normal operation

It's right there on the last 2 pages of the bh1415f datasheet from ROHM.

savnik
- 7th July 2007, 20:23
Do you not have the bh1415f datasheet?
It explains how to set the frequency in there...all easily done with PBP's SHIFTOUT commands...

bits 0 - 15
1,0,1,1,1,1,1,1,1,1,0,1,0,0,1,0

bits 0-10 = frequency, in this case 102.1Mhz
bit 11 = mode, in this case stereo
bits 12-13 = phase detector operation, in this case normal
bits 14-15 = test mode, in this case normal operation

It's right there on the last 2 pages of the bh1415f datasheet from ROHM.
I have the bh1415f datasheet and i have read , but i don't know how to send the data to bh1415f , because this chip has data,clock and enable
For the TSA551 i don't have problem.I have use it many times , but this have only data and clock and use I2CWRITE SDA,SCL,ADDR1,[HI,LO,$8E] to send the data

skimask
- 7th July 2007, 21:26
I have the bh1415f datasheet and i have read , but i don't know how to send the data to bh1415f , because this chip has data,clock and enable
For the TSA551 i don't have problem.I have use it many times , but this have only data and clock and use I2CWRITE SDA,SCL,ADDR1,[HI,LO,$8E] to send the data

SHIFTOUT SHIFTOUT SHIFTOUT SHIFTOUT

skimask
- 7th July 2007, 21:35
I have the bh1415f datasheet and i have read , but i don't know how to send the data to bh1415f , because this chip has data,clock and enable
For the TSA551 i don't have problem.I have use it many times , but this have only data and clock and use I2CWRITE SDA,SCL,ADDR1,[HI,LO,$8E] to send the data



freq var word
dataout var word
hardcode var word
chipselect var portb.0 'or whatever pin you've got set for the chip select
datapin var portb.1 'or whatever pin you've got set for the data pin
clockpin var portb.2 'or whatever pin you've got set for the clock pin

hardcode = %0100100000000000 'hardcoded values - not in test mode, phase detector normal, stereo operation, doesn't (shouldn't?) change

freq = 1021 'frequency desired = 102.1 Mhz
dataout = hardcode + freq 'add in frequency value
high chipselect
shiftout datapin , clockpin , 0 , [ dataout/16 ]
low chipselect

savnik
- 7th July 2007, 22:02
SHIFTOUT SHIFTOUT SHIFTOUT SHIFTOUT
I have understand , but i don't have use before the command shiftout.




Include "modedefs.bas"

datapin var PORTB.0
clockpin var PORTB.1
enablepin var PORTB.2

dataout var word

dataout = %1011111111010010

high enablepin
shiftout datapin , clockpin , 0 , [ dataout\16 ]
low enablepin

savnik
- 27th August 2007, 22:33
freq var word
dataout var word
hardcode var word
chipselect var portb.0 'or whatever pin you've got set for the chip select
datapin var portb.1 'or whatever pin you've got set for the data pin
clockpin var portb.2 'or whatever pin you've got set for the clock pin

hardcode = %0100100000000000 'hardcoded values - not in test mode, phase detector normal, stereo operation, doesn't (shouldn't?) change

freq = 1021 'frequency desired = 102.1 Mhz
dataout = hardcode + freq 'add in frequency value
high chipselect
shiftout datapin , clockpin , 0 , [ dataout/16 ]
low chipselect

I test today this code but don't work