![Infineon 82C900 Скачать руководство пользователя страница 22](http://html1.mh-extra.com/html/infineon/82c900/82c900_application-note_2055171022.webp)
AP29002
Standalone TwinCAN Controller
Using special features of the 82C900
Application Note
21
V 1.0, 2004-02
Functions to access the 82C900 via parallel bus:
The variable _82C900 is defined as:
#define _82C900 ((unsigned char volatile xhuge*) 0x200000)
It is the base address of the 82C900 with the described configuration for BUSCON3.
Next is the source code of the functions to access the 82C900.
The following functions will be copied into the IRAM. They are located in the file
P_ACS.C (short for “Parallel Access”). It is important that the name of the file is the
same as the user section. The next statement must be placed before the code that is
copied into the IRAM.
#pragma RENAMECLASS (NCODE=P_ACS_SOURCE)
// read data from adr
unsigned char P_Read(byte adr)
{
unsigned char ret;
_atomic_(1);// no interrupts during transfer
IEN = 0;// disable interrupts
ret = *(adr);// read access to the 82C900
IEN = 1;// enable interrupts again
return
ret;
}
// write data to adr
void P_Write(byte adr, byte data)
{
_atomic_(1);// no interrupts during transfer
IEN = 0;// disable interrupts
*(adr) = data; // write access to the 82C900
_nop_();// to guarantee the timing at fCPU=20MHz
IEN = 1;// enable interrupts
}
These functions fulfill the bus timings for a 20MHz CPU clock. If the microcontroller is
used with a higher clock speed, _nop_() can be inserted after the read/write statement
to lengthen the time between /RD /WR high and the next ALE signal. The functions are
copied to IRAM in the parallel_init() function that is described later.