Hi using the nrf24e1, in the datasheet it says to set a pin on a particular port to an input or output for example port 0 pin 1 to output:
P0_DIR.1 = 0;
but this doesnt seem to be recognised in keil. what is the correct code for this?
cheers.
"cant understand how it is doing what it says its doing??"
Which bit don't you understand - the 'C' syntax, or the comment.
The 'C' syntax is setting bit-1 in P0_DIR - but your original post was, apparently trying to clear that bit.
Whether clearing that bit in that register does actually set P0.1 (RxD) to be an input is something you'll have to check in the Datasheet.
Comments can, of course, be wrong...
Its the 'c' syntax, how is it that 0x02 is known to be setting P0.1?
0x01 = 1<<0 = 1 = bit 0 (least significant bit) 0x02 = 1<<1 = 2 = bit 1 0x04 = 1<<2 = 4 = bit 2 0x08 = 1<<3 = 8 = bit 3 0x10 = 1<<4 = 16 = bit 4 0x20 = 1<<5 = 32 = bit 5 0x40 = 1<<6 = 64 = bit 6 0x80 = 1<<7 = 128 = bit 7 (most significant bit)
ahh ok, i see, well i what i want to do is to set P0.5 as an input and to only transmit when a pulse is received on that pin, i have set pulse_pin (p0.5) as an input using the above, along with p0.1 for other reasons.
i.e. P0_DIR = 0x22;
in init() function i have set pulse_pin = 0 then the code for main() is as follows:
if (pulse_pin = 1) { transmitter() }
is this the correct way of 'asking' if a pulse is received, i.e. goes high from a voltage.
thanks again
P0_DIR |= 0x02; // P0.1 (RxD) is input
"how is it that 0x02 is known to be setting P0.1?"
It isn't!
It's setting P0_DIR.1 - which, if the comment is to be believed, configures P0.1 to be an input
"i have set pulse_pin (p0.5) as an input ... i have set pulse_pin = 0"
What happens on this chip when you write to an input pin?!