Nyh wrote: DrCoolZic wrote:
I choose a prescale of 200 wich gives a period of about 81µs and an overflow every 20 ms. As I get back to the timer in less than 20 ms I can test for overflow and proceed accordingly, but it would probably be better to setup an interupt handler on overflow, but I do not know (yet) how to write that in C.
It is possible to do that in Pure
C but this is dark magic. You can only use code that doesn't change registers.
Code: Select all
void rte(void) 0x4E73;
volatile long int counter=0;
*(char*)0xfffa0fL=0xDF; /* clear interrupt mask */
Jdisint(13); /* disable timer A */
Xbtimer(0, 1, 128, handler); /* install and enable timer A handler */
Yes this is really dark magic! and extremely
elegant solution compared to the code I wrote manipulating the timer registers, going in/out of sv mode ... !!!!
Lets see if I can make sense out of this:
void rte(void) 0x4E73;
I remember that you already mentioned this capability of Pure
C to drop "Assembly opcode" inside C code. I have been looking everywhere in the Pure
C help files but could not find any information on this ?
How did you found about this feature? What is the syntax? If I remember correctly you also gave examples passing an argument. Something like func(long value) 0x???? In that case the code dropped would be ???? folowed by value ? Is it limited to Only one argument or more ? What type of argument char, short, long ... ? This looke extremely powerful and I am interested by information even if it is not really portable.
So with a name like rte I guessed that the 0x4E73 is instruction for return from exception (probably another name for interrupt in 68k terminology - sorry I am more an x86 guy
By the way I have dowloaded lots of documents on motorola (user's guide, ... ) but none of them have a simple table that list by hex value the associated opcode? So I can easely find that $4e73 is an RTE operation ??? Any pointer to such document ?
The rest of the code is relatively clear
but I have few questions:
First: in the handler you access register directly and use RTE. All this needs to be done in SV mode, so my guess is that the handler declare in Xbtimer is called in SV mode (humm this sound pretty obvious)
Second: You used Jdisint() ? This is suppose to disable interrupt ? I was rather expecting Jenabint() function to be called ? so that timer can generate interrupt ?
I noted the usage of volatile, so that if counter is used in some other places in the code it does not get "optimized".Now another question related on the subject of limitations while accessing files and folders.
I was running some tests to copy a large tree from one partition to another using a new hd driver in dev. from ppera and the program stoped on an invalid file name to read. It happen that this tree has been generated on a PC with some files using long file name. The files shows in Atari with shorter name and usage of "~" char (I think this is part of the DOS 8.3 name mapping). According to ppera this is the cause of the problem (problem in Fsfirst() and Fsnext()) and indeed on on a tree without "long names" everything works fine. However I run the exact same test without any problem using HDD 8.2 !?!
So here is my question: does anybody knows if HDDriver does something to correct this problem ???
Another interesting way to see this problem is by asking "file information" on a large tree with "long names": it returns a correct number of files and folders but an invalid size (even using all sorts of invalid character in the size field!).