Well, simple thing I’m trying and just cannot really nail it.
I’m leaving all the initialization on .NET, doesn’t really performance on init, so in .NET, on connector 6 I set pin 3 to output and pin 9 to input. Both are connected on the extender, as shown on the photo attached.
Writing pin 3 affects pin 9 state, which is as expected. Here’s a short example of what I mean:
DigitalInput pin9 = extender.SetupDigitalInput(GT.Socket.Pin.Nine, GlitchFilterMode.Off, ResistorMode.Disabled);
DigitalOutput pin3 = extender.SetupDigitalOutput(GT.Socket.Pin.Three, false);
bool boolVar = true;
while (true)
{
boolVar = !boolVar;
pin3.Write(boolVar);
Debug.Print(pin9.Read().ToString()); // This output gives exactly what I write to Pin3
}
Now I’m trying the same thing from RLPLite (with all the same .net settings for pins).
Here’s an example of what I’m doing:
#define RegA (AT91_CAST(AT91PS_PIO) 0xFFFFF400) // (PIOA) Base Address
#define RegD (AT91_CAST(AT91PS_PIO) 0xFFFFFA00) // (PIOD) Base Address
const unsigned int Pin17 = 1 << 17;
const unsigned int Pin27 = 1 << 24;
while(1)
{
RegD->PIO_CODR = Pin17; //clears output. This is pin 3 on connector #6
//Delay
for(i=0; i<14285393; i++){}
RegD->PIO_SODR = Pin17; //set output data to 1;
//Delay
for(i=0; i<14285393; i++){}
}
Now how do I correctly read the input from the register (PIOA)? According to datasheet, [em]"(PIO_PDSR) Pin Data Status Register"[/em] should give my the data on required register, something like [em]RegA->PIO_PDSR & Pin24[/em] for PA24 on PIOA. But according to what I see, PIO_PDSR doesn’t really reflect anything I expect.
Now I’m sure I’m doing something wrong or I just doesn’t understand the purpose of PIO_PDSR and there should be different variable…
I’m running it from NETMF.
The problem with while(1) loop I already had and solved. Yes, if you enter RLP mode with while(1) loop, you cannot deploy new code anymore - the solution is FW update. But in order to avoid such problems, I’m NOT entering RLP mode on the boot. I’m using button module as a trigger for RLP, so after simple reset I’m back to NETMF.
Anyways, the code here is only for an example - it’s not the problem. I’m stuck with reading pin status. So either I’m using incorrect output commands or incorrectly reading from for input.
which should return status of the whole register. As I understand, binary representation of this number will give status of each bit, while each bit represent each pin controlled by that register.
Only one RLP code is running (AFAIK there’s no option to execute more then one RLP code).
The endless loop I showed in code example, is irrelevant. It was just for example of toggling on and off some pin.
I’m using the button to execute one RLP code.
Now about the clock- I also assume. I never actually enabled it manually, but I assume it is enabled at some point of the boot. But it’s a good point, I will definitely recheck it. Any chance you remember how do I enable/disable or check its status?
But what I actually get is 4271160 = 10000010010110000[em]1110[/em]00
Note that only one bit got off, which looks like only the clock of PIOA went off.
Am I doing something wrong? Or I just misunderstood the datasheet???
@ Stargazer - You may want to check PIO_PSR to make sure the PIO controller does in fact control the pins you are using and not the peripheral see 31.4.2 in the manual. Is the register class available for Hydra?