avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-chat] PC Communication


From: Rutger Nijlunsing
Subject: Re: [avr-chat] PC Communication
Date: Mon, 19 Mar 2007 23:08:19 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

On Mon, Mar 19, 2007 at 03:12:43PM -0600, Suhas Pharkute wrote:
>    Hi,
> 
>    Is there any way to communicate to PC back using ISP when program
>    execution is in place.
> 
>    Or can I write a loop that will look for PC input/output for interaction
> 
>    I know I can read/write a block from ISP but that will need to put
>    Processor in prog mode and will halt the exection, correct?
> 
>    Please help
> 
>    Suhas

I don't know whether this is what you require, but it might help you
(and others).

When I soldered an ATMEGA8 CPU and had it programmed via the parallel
port on Linux, I wanted to know whether it 'worked' and having a way
to send debug output to the PC without having to solder extra wires
besides the absolute minimal ones. Since the parallel ISP lines (MISO
+ MOSI + SCK) were already in place to be able to program the ATMEGA,
it seemed natural to me to have some functions sending data from the
ATMEL to the PC. However, I could not find anything on the net.

So I came up with a very simple to implement protocol to send bytes.

>From msio.h:
// On the ATMEL side:
//   - uses a polling loop which monitors the clock (SCK)
//   - uses MISO to send the data bit by bit
//   - continues after a timeout if no one is listening on the other
//     side.
// On the host PC side:
//   - uses the parallel port (could be extended though)
//   - uses SCK to drive the clock to indicate the ATMEL we're ready
//     to receive the next bit.

Usage:
   - On the host PC, compile msio_host.c:
     gcc -Wall -o msio_host msio_host.c
   - For the ATMEGA8, compile msio.c together with your application.
   - Test it by doing in your main:
      #include "msio.h"
      msioInit();
      msioSendString("Hello world!\n");
   - program your ATMEGA the normal way with avrdude
   - start msio_host on the PC.
     This will reset the ATMEGA, which will start the program uploaded
     and will wait from output from the ATMEGA.
     
It currently assumes:
   - PB5 == SCK; PB4 == MISO; PB3 == MOSI
     ...which is true for the ATMEGA8. Change all occurances of PB5,
     PB4 and PB3 in msio.c if configuration is different.
   - A parallel port programmer configured as (pins):
     #define RESET 16
     #define SCK 1
     #define MOSI 2
     #define MISO 11
     Change in msio_host.c to your liking.
   - Linux with module 'ppdev' loaded and being able to access
     /dev/parport0 directly.

Good luck.

Regards,
Rutger.

-- 
Rutger Nijlunsing ---------------------------------- eludias ed dse.nl
never attribute to a conspiracy which can be explained by incompetence
----------------------------------------------------------------------

Attachment: msio.h
Description: Text Data

Attachment: msio.c
Description: Text Data

Attachment: msio_host.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]