AVR I/O experience

General discussion on mikroPascal for AVR.
Post Reply
Author
Message
cooqo
Posts: 5
Joined: 16 Apr 2008 02:30

AVR I/O experience

#1 Post by cooqo » 23 Apr 2008 06:08

:oops:
Phenomenon : use the time interrupt of ATmega64 to produce a pulse square wave with static frequency, the IO is PORTB7.

/* BYTE STRUCTION -----------------------------------------------------------*/
typedef union
{
unsigned int byte;
struct
{
unsigned b0 :1;
unsigned b1 :1;
unsigned b2 :1;
unsigned b3 :1;
unsigned b4 :1;
unsigned b5 :1;
unsigned b6 :1;
unsigned b7 :1;
}bit;
}BYTE_STRUCT;
/*-----------------------------------------------------------------------*/
#define _MY_SFR_IO8(io_addr) _MY_MMIO_BYTE((io_addr) + 0x20)
#define _MY_SFR_MEM8(mem_addr) _MY_MMIO_BYTE(mem_addr)
#define _MY_MMIO_BYTE(mem_addr) (*(volatile BYTE_STRUCT *)(mem_addr))
/*-----------------------------------------------------------------------*/
#define PIN_B _MY_SFR_IO8(0x16)
#define DDR_B _MY_SFR_IO8(0x17)
#define PORT_B _MY_SFR_IO8(0x18)

#define ioWatchdog PORT_B.bit.b5
#define ioPulse PORT_B.bit.b7
/*-----------------------------------------------------------------------*/

#define INPUT 0
#define OUTPUT 1
/*-----------------------------------------------------------------------*/

#define CLRWDT { \
asm( "WDR" ); \
ioWatchdogDir = OUTPUT; \
if( ioWatchdog ) ioWatchdog = 0;\
else ioWatchdog = 1;\
} /* clr watchdog */


ATmega64 Datasheet : http://www.chinaicmart.com/suppliers/164/ATmega64.html

pykedgew
Posts: 164
Joined: 10 Dec 2005 02:22
Location: Brisbane Australia

#2 Post by pykedgew » 27 Apr 2008 00:47

Hi cooqo

The source code is not Pascal.
There is no "C compiler" for AVR ATxx series.
Pascal, Basic & C compiler for 8051 are available.

Cheers
Ken

Post Reply

Return to “mikroPascal for AVR General”