1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Atmega <> USO BASCOM issue

Discussion in 'Miscellaneous' started by jakob, Feb 14, 2010.

  1. jakob

    jakob New Member

    Joined:
    Sep 4, 2009
    Messages:
    83
    Location:
    Frankfurt
    Balance:
    313Coins
    Ratings:
    +4 / 0 / -0
    Hi,

    I'm trying to read data from USO with an uC. But the uC won't read anything. I'm using BASCOM and I tried several codes. If the uC recieves any data, the LED on pinb.1 should toggle. It's working fine with hyperterminal, but not with X-Sim.

    USO string I'm using is just ~115~ (ASCII S). So USO should send 01010011 every 33ms to my uC and toggle the LED.

    Code:
    $regfile = m88def.dat
    $crystal = 8000000
    $baud = 19200
    
    Config Serialin = Buffered , Size = 20
    Config Pinb.1 = Output
    Led Alias Portb.1
    
    Dim A As Byte
    
    Enable Interrupts
    
    Do
    A = Inkey()
    If A <> 0 Then
    Toggle Led
    End If
    Loop
    End
    Would be great if anone could help
  2. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    328Coins
    Ratings:
    +4 / 0 / -0
    I don't know bascom, and I really have no clue what your compiler does with those instructions.
    I can help you out if it was AVR Studio.

    If it works with hyperterminal, it should work with x-sim too. What frequency and baudrate are you using?

    BTW, '01010011' is 83. 115 is '01110011'
  3. jakob

    jakob New Member

    Joined:
    Sep 4, 2009
    Messages:
    83
    Location:
    Frankfurt
    Balance:
    313Coins
    Ratings:
    +4 / 0 / -0
    Baud is 19200/8/N/1

    I've tried INKEY, WAITKEY and INPUT. Nothing works...
  4. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    328Coins
    Ratings:
    +4 / 0 / -0
    Try to lower the baud rate and see if that helps. Other than that, the only advice I can give you is to ask in a related forum, preferably a BASCOM forum. Or you can get AVR Studio with the WinAVR compiler library.
  5. jakob

    jakob New Member

    Joined:
    Sep 4, 2009
    Messages:
    83
    Location:
    Frankfurt
    Balance:
    313Coins
    Ratings:
    +4 / 0 / -0
    WinAVR would mean C. I'm not firm with C or Assembler.

    I'll try it with lower baud rate.
  6. jakob

    jakob New Member

    Joined:
    Sep 4, 2009
    Messages:
    83
    Location:
    Frankfurt
    Balance:
    313Coins
    Ratings:
    +4 / 0 / -0
    Thanks, will check it.

    I will also try Ischarwaiting, Interrupt recieve and with an external crystal. Atm just the internal RC is active. This may cause this problem, too.
  7. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    328Coins
    Ratings:
    +4 / 0 / -0
    The internal oscillator will definietly cause problems. It is nowhere near stable enough for the baudrate you are trying to use.
  8. jakob

    jakob New Member

    Joined:
    Sep 4, 2009
    Messages:
    83
    Location:
    Frankfurt
    Balance:
    313Coins
    Ratings:
    +4 / 0 / -0
    I Think, I got it.

    Every time USO (X-Sim) starts up and connects to my uC, it sends:

    Code:
    COM port is opened
    <20100218000422.102 SYS>
    Baud rate 19200
    <20100218000422.105 SYS>
    RTS off
    <20100218000422.108 SYS>
    DTR on
    <20100218000422.111 SYS>
    Data bits=8, Stop bits=1, Parity=None
    <20100218000422.111 SYS>
    Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13
    <20100218000422.114 SYS>
    Handflow: ControlHandShake=(DTR_CONTROL), FlowReplace=(), XonLimit=2048, XoffLimit=512
    <20100218000422.114 SYS>
    Set timeouts: ReadInterval=50, ReadTotalTimeoutMultiplier=10, ReadTotalTimeoutConstant=50, WriteTotalTimeoutMultiplier=0, WriteTotalTimeoutConstant=0
    DTR on is the problem. It resets the uC all the time because the DTR pin of the FT232RL is connected to RESET. My other test board still needs some soldering. But I guess it should be ready this weekend.
  9. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    328Coins
    Ratings:
    +4 / 0 / -0
    What kind of dev board are u using? Can you just disconnect that pin from the circuit? All you really need is TX and RX.
  10. jakob

    jakob New Member

    Joined:
    Sep 4, 2009
    Messages:
    83
    Location:
    Frankfurt
    Balance:
    313Coins
    Ratings:
    +4 / 0 / -0
    Its a SMD TQFP32 Atmega88 board + FT232RL. The RESET pin has a pull down (4k7) and is also connected to FT232 DTR. I won't damage the PCB by cutting the connection.

    My DIY board without DTR connection is nearly done.
  11. jakob

    jakob New Member

    Joined:
    Sep 4, 2009
    Messages:
    83
    Location:
    Frankfurt
    Balance:
    313Coins
    Ratings:
    +4 / 0 / -0
    Alright, its working brilliant without DTR.