I have many times wanted to use buffered ports (fast deterministic data output) at one time and unbuffered ports at another.
Is it possible for me to call in sequence:
mybufferedportapplication();
myunbufferedportapp();
?
If so, what is the syntax in XC? It appears ports are assigned at the beginning of the code and can never be changed.
Reconfiguring buffered ports on the fly possible?
-
- XCore Addict
- Posts: 162
- Joined: Thu Dec 31, 2009 8:51 am
-
- Active Member
- Posts: 38
- Joined: Tue Jul 13, 2010 2:57 pm
True.
The xs1.h has some useful functions to set port drive "type" (in, out, drive low, drive high...) but nothing about the "buffering".
You could use few "asm in-lines" for that - to set TW (transfer width) and buffered/unbuffered flags on the port resource.
Something like
but I'm not sure if it's necessary to stop/clear port before and re-start it later.
There are port transfer width and sift count parameters which which I'm not sure about the usage.
I suppose the "shift bits" should be equal to the port bits (or what??) and the transfer width to the actual "chunk" you which to put/get from the port buffer (shift register).
I'm also very intrigued about the 16-bit transfter - port:16 - which is not supported?!?!?! any idea why?
regards,
mculibrk
The xs1.h has some useful functions to set port drive "type" (in, out, drive low, drive high...) but nothing about the "buffering".
You could use few "asm in-lines" for that - to set TW (transfer width) and buffered/unbuffered flags on the port resource.
Something like
Code: Select all
#define SETPORTBUFFERED(p, bits) \
asm("\
setc res[%0], 0x200f \n \
settw res[%0], %1 \n \
" : : "r"(p), "r"(bits) );
#define SETPORTUNBUFFERED(p) asm("setc res[%r], 0x2007" ::"r"(p));
There are port transfer width and sift count parameters which which I'm not sure about the usage.
I suppose the "shift bits" should be equal to the port bits (or what??) and the transfer width to the actual "chunk" you which to put/get from the port buffer (shift register).
I'm also very intrigued about the 16-bit transfter - port:16 - which is not supported?!?!?! any idea why?
regards,
mculibrk
-
- Respected Member
- Posts: 363
- Joined: Thu Dec 10, 2009 10:17 pm
Oh thanks i remember having that problem before.