Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Off to a rocky start with Swordfish Basic

Status
Not open for further replies.
This sends it to the LCD the sony IR code
Code:
//By BE80BE  //
Device = 18F1320

Clock = 8 // 8MHz clock
Config OSC = INTIO2, WDT = OFF, LVP = OFF
Include "IntOSC8.bas"
Include "LCD.bas" 
Include "utils.bas" 
Include "convert.bas" 
Dim IR_mod As PORTA.0  //pin the IR module on
Dim i As Byte
Dim IR_cmd As Byte
Dim loop As Byte
ADCON1=$70  
// some LCD options...
#option LCD_DATA = PORTB.4
#option LCD_RS = PORTB.2
#option LCD_EN = PORTB.3

Input (IR_mod)

SetAllDigital
IR_cmd = 0
While true

start:

  While (IR_mod = 1)   //loop while high
    i = 0
  Wend

While (IR_mod = 0)   //loop while low
    i = i + 1
    DelayUS (200)
  Wend
    If i <= 10 GoTo start     //if to short goto start
    If i >= 14 GoTo start     //if to long goto start
    i = 0                     // reset count
    loop = 0
        For loop = 0 To 6 //was 7 but thats too long need a 6 here for 7 loops LOL
            IR_cmd = IR_cmd >>1        // this gets the 0 bits
                While (IR_mod = 1)
                    i = 0
                Wend
                While (IR_mod = 0)
                    i = i + 1
                    DelayUS (200)
                Wend
            If (i >= 6) Then 
                IR_cmd = (IR_cmd Or $40) //this gets the 1 bits
            End If 
        Next 
    Cls
    LCD.Write("IR_cmd = ",  BinToStr(IR_cmd))
   DelayMS(250)     
    //leds = IR_cmd   // this is just a test that outputs the binary 
                    // value to leds on portb
Wend

It shifts in a 1 by or'ing with $40

Code:
IR_cmd = (IR_cmd Or $40) //this gets the 1 bits
 
The 4550 needs the USB to run at 96MHz and usually the CPU gets 48MHz (12MIPs)

Tell me what crystal you're using (USB won't work from the INTOSC) and I can tell you the PLL settings, it's actually a page in the datasheet with all possible crystal combinations.
 
The 4550 needs the USB to run at 96MHz and usually the CPU gets 48MHz (12MIPs)

Tell me what crystal you're using (USB won't work from the INTOSC) and I can tell you the PLL settings, it's actually a page in the datasheet with all possible crystal combinations.

Bill I have no problems with USB and Pll. I no it don't work from INTOSC It using the crystal

What I don't get is how we got from A to B here. Let get back to the OP and helping him with Swordfish Basic

This is what got the PLL thing going
Does the module check for out of spec frequencies. The max clock for the 4550 is 48MHz (12MIPs)

You can't use it for that it, sets only the INTOSC and PLL if your chip has it for the INTOSC.

Bill I didn't want to get into setting up USB and all but if you have some setting for the 18f14k50 I would love to see them Swordfish just don't seem to like that chip
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top