Pacetech
09-20-05, 09:00 PM
I'm getting a wierd hardware interaction that I can't understand/identify.
I'm using Timer A for reading an optical encoder, as follows
\ Encoder A - TA0/PHASEA0
\ Encoder B - TA1/PHASEB0
\ Encoder Index - TA2/INDEX
I just initialize as follows:
COLD
SCRUB
HEX
0040 0E40 SET-BITS ( Set bit 6 = XIP )
Then I can read the encoder
0E48 @ .
Now when I setup my SPI EEPROM, I am using PWMA5 as a chip select, as well as a PWMA0 and PWMA1
: SPI-INIT ( - )
PWMA1 ON \ PWMA1/ISA1 - /HOLD - Normally high, pull low to suspend
PWMA0 ON \ PWMA0/ISA0 - /WP - Normally high to enable writing
PWMA5 ON \ Set Slave Select high
50 0F20 ! \ Configue SPI without enabling - SPI MODE 0
07 0F21 ! \ Configure Word Size
52 0F20 ! \ Set just the SPIE - enable bit
; EEWORD
Well, as soon as I execute this code, I can no longer read valid info from the encoder, it just gives me the same number.
So, I narrowed it down to PWMA0 ON as being the culprit and tried to manually set the PWMA pins without using the ISOMAX ON command. To make it short, I read up on PWM and found this post
http://www.newmicros.com/discussion/showthread.php?t=546
It turns out the problem is caused by setting PAD_EN [bit 15] on the PMOUT register [0E03]. This is the output pad enable bit.
So once I set the PWM pins to be outputs, my Timer A no longer reads the right value. Turn it off and it works again.
I cannot find anything in the documentation that explains this - any ideas?
I'm using Timer A for reading an optical encoder, as follows
\ Encoder A - TA0/PHASEA0
\ Encoder B - TA1/PHASEB0
\ Encoder Index - TA2/INDEX
I just initialize as follows:
COLD
SCRUB
HEX
0040 0E40 SET-BITS ( Set bit 6 = XIP )
Then I can read the encoder
0E48 @ .
Now when I setup my SPI EEPROM, I am using PWMA5 as a chip select, as well as a PWMA0 and PWMA1
: SPI-INIT ( - )
PWMA1 ON \ PWMA1/ISA1 - /HOLD - Normally high, pull low to suspend
PWMA0 ON \ PWMA0/ISA0 - /WP - Normally high to enable writing
PWMA5 ON \ Set Slave Select high
50 0F20 ! \ Configue SPI without enabling - SPI MODE 0
07 0F21 ! \ Configure Word Size
52 0F20 ! \ Set just the SPIE - enable bit
; EEWORD
Well, as soon as I execute this code, I can no longer read valid info from the encoder, it just gives me the same number.
So, I narrowed it down to PWMA0 ON as being the culprit and tried to manually set the PWMA pins without using the ISOMAX ON command. To make it short, I read up on PWM and found this post
http://www.newmicros.com/discussion/showthread.php?t=546
It turns out the problem is caused by setting PAD_EN [bit 15] on the PMOUT register [0E03]. This is the output pad enable bit.
So once I set the PWM pins to be outputs, my Timer A no longer reads the right value. Turn it off and it works again.
I cannot find anything in the documentation that explains this - any ideas?