communication with TSA5511 PLL synthetizer

General discussion on mikroPascal.
Post Reply
Author
Message
andrei_pic16
Posts: 23
Joined: 19 Jan 2005 22:34

communication with TSA5511 PLL synthetizer

#1 Post by andrei_pic16 » 28 Jan 2005 21:44

i have a question...
the soft_i2c_start routine needs to have the slave connected in order to work or there is a problem?
i tried to test it with leds connected to sda and scl and the program locks up there at soft_i2c_start....do someone have an answer? thanks :)

pued
Posts: 7
Joined: 21 Jun 2012 09:57
Location: sisaket

Re: communication with TSA5511 PLL synthetizer

#2 Post by pued » 23 Jun 2012 15:30

Code: Select all

program tsa5511_16f628_16x2

' Lcd module connections
dim LCD_RS as sbit at RB4_bit
    LCD_EN as sbit at RA3_bit
    LCD_D4 as sbit at RB0_bit
    LCD_D5 as sbit at RB1_bit
    LCD_D6 as sbit at RB2_bit
    LCD_D7 as sbit at RB3_bit

    LCD_RS_Direction as sbit at TRISB4_bit
    LCD_EN_Direction as sbit at TRISA3_bit
    LCD_D4_Direction as sbit at TRISB0_bit
    LCD_D5_Direction as sbit at TRISB1_bit
    LCD_D6_Direction as sbit at TRISB2_bit
    LCD_D7_Direction as sbit at TRISB3_bit
' End Lcd module connections

    ' Declarations section
dim FREQ_step as byte
    FREQ_Khz  as word
    FREQ_Mhz  as word
    FREQ      as word
    F_CONTROL as word
    ADRESS    as byte
'dim LO        as FREQ,lowbyte
'dim HI        as FREQ,highbyte

' Software I2C connections
dim Soft_I2C_Scl  as sbit at RA0_bit
    Soft_I2C_Sda  as sbit at RA1_bit
    Soft_I2C_Scl_Direction as sbit at TRISA0_bit
    Soft_I2C_Sda_Direction as sbit at TRISA1_bit
' End Software I2C connections
sub procedure Display_freq()
    if FREQ_Khz < 100 and (FREQ_Mhz < 10) then
       lcd_out (1,7," ")
       lcd_chr (1,8,FREQ_Khz)
       lcd_out (1,9,".0")
       lcd_chr (1,11,(FREQ_Mhz))
       lcd_out (1,13," ")
       lcd_out (1,14,"MHz")
     end if
    if FREQ_Khz < 100 and (FREQ_Mhz > 5) then
       lcd_out (1,7," ")
       lcd_chr (1,8,FREQ_Khz)
       lcd_out (1,9,".")
       lcd_chr (1,10,FREQ_Mhz)
       lcd_out (1,13," ")
       lcd_out (1,14,"MHz")
    end if
    if FREQ_Khz > 99 and (FREQ_Mhz < 10) then
       lcd_chr (1,7,FREQ_Khz)
       lcd_out (1,8,".0")
       lcd_chr (1,10,FREQ_Mhz)
       lcd_out (1,13," ")
       lcd_out (1,14,"MHz")
    end if
    if FREQ_Khz > 99 and (FREQ_Mhz > 5) then
       lcd_chr (1,7,FREQ_Khz)
       lcd_out (1,9,".")
       lcd_chr (1,10,FREQ_Mhz)
       lcd_out (1,13," ")
       lcd_out (1,14,"MHz")
    end if
  end sub
const character as byte[8] = (17,14,14,21,4,4,14,31)

 sub procedure CustomChar(dim pos_row as byte, dim pos_char as byte)
  dim i as byte
    Lcd_Cmd(80)
    for i = 0 to 7
      Lcd_Chr_CP(character[i])
    next i
    Lcd_Cmd(_LCD_RETURN_HOME)
    Lcd_Chr(1,1, 2)
 end sub
main:
    TRISA = 0x00
    TRISB = 0xE0
    porta.2  = 0
      Lcd_Init()
      Lcd_Cmd(_LCD_CLEAR)            ' Clear display
      Lcd_Cmd(_LCD_CURSOR_OFF)       ' Cursor off
      Lcd_Out(1,1," FM TRANSMITTER ")              ' Write text in first row
      Lcd_Out(2,1,"*SISAKET PLL V1*")              ' Write text in second row

      Delay_ms(1000)
    ADRESS = 0xC0
    FREQ_step = EEPROM_Read (02)
    if FREQ_step > 0 then
         GOTO TSA
    end if

 FREQ_set:
    delay_ms(100)
    FREQ_Mhz = (FREQ_step * 100 / 2) / 10
    FREQ_Khz = (FREQ_step * 100 / 2) / 100
    Lcd_Init()
    Lcd_Cmd(_LCD_CLEAR)            ' Clear display
    Lcd_Cmd(_LCD_CURSOR_OFF)
    lcd_out(1,1,"SET")
    Display_freq()
    lcd_out(2,1,"POWER  15   WATT")
    IF PORTB.5 = 1 THEN
       goto UP_FREQ
    end if
    IF PORTB.6 = 1 THEN
       goto SET_FREQ
    end if
    IF PORTB.7 = 1 THEN
       goto DOWN_FREQ
    END IF
    FREQ = FREQ_STEP
    Soft_I2C_Start()
    adress = Soft_I2C_Write(0x10)   'ADRESS,[HI,LO,$8E,$10]
    adress = Soft_I2C_Write(0x8E)
    Soft_I2C_Stop()
    GOTO FREQ_set

 UP_FREQ:
     DELAY_MS(50)
     FREQ_STEP = FREQ_STEP + 1
     IF FREQ_STEP > 216 THEN
        FREQ_STEP = 175
     end if
     GOTO FREQ_SET
     
 DOWN_FREQ:
     DELAY_MS(50)
     FREQ_STEP = FREQ_STEP - 1
     IF FREQ_STEP > 175 THEN
        FREQ_STEP = 216
     end if
     GOTO FREQ_SET

 SET_FREQ:
    EEPROM_WRITE (02,FREQ_STEP)
    DELAY_MS(200)

 TSA:
    FREQ = FREQ_STEP
    Soft_I2C_Start()
    adress = Soft_I2C_Write(0x00) 'I2COUT SDA,SCL,ADRESS,[HI,LO,$8E,$00]
    F_CONTROL = Soft_I2C_Read(0)       'I2CIN SDA,SCL,ADRESS,[F_CONTROL]
    Soft_I2C_Stop()
    IF F_CONTROL.6 = 1 THEN 
       goto KITLI
    end if
    FREQ_Mhz = (FREQ_step*100/2)/10
    FREQ_Khz = (FREQ_STEP*100/2)/100
    Lcd_Init()
    Lcd_Cmd(_LCD_CLEAR)            ' Clear display
    Lcd_Cmd(_LCD_CURSOR_OFF)
    lcd_out(1,1,"SCAN")
    Display_freq()
      lcd_out(2,1,"POWER   15    WATT")
    If  PORTB.6 = 1   Then
        goto FREQ_set
    end if
    
 KITLI:
    Soft_I2C_Start()
    adress = Soft_I2C_Write(0x21)  'I2COUT SDA,SCL,ADRESS,[HI,LO,$8E,$21]
    Soft_I2C_Stop()
    FREQ_Mhz = (FREQ_step*100/2)/10
    FREQ_Khz = (FREQ_STEP*100/2)/100
    Lcd_Init()
    Lcd_Cmd(_LCD_CLEAR)            ' Clear display
    Lcd_Cmd(_LCD_CURSOR_OFF)
    lcd_out(1,1,"ONAIR")
    Display_freq()
    lcd_out(2,1,"POWER   15    WATT")
    If  PORTB.6 = 1   Then    
        goto FREQ_set
    end if

end.

Post Reply

Return to “mikroPascal General”