Heres some debug listing, it has invalid opcodes neatly commented. How can this happen? I must be doing something incorrectly. Below that is my source file. When I run the program, ADC always reads 0 and it crashes after a while. Sorry about tabs being lost in the paste, they only ever go 1 level deep.
Thanks,
J JORDAN
20002DD6: 0A004572 eori.b #0x72,d0
20002DDA: 726F moveq #111,d1
20002DDC: 7220 moveq #32,d1
20002DDE: 6F6E ble.s 0x20002E4E (0x20002e4e) ; 0x20002e4e
20002DE0: 206F7065 movea.l 28773(a7),a0
20002DE4: 7261 moveq #97,d1
20002DE6: 6E64 bgt.s 0x20002E4C (0x20002e4c) ; 0x20002e4c
20002DE8: 20726561640A movea.l ([25610,a2]),a0
20002DEE: 00005265 ori.b #0x65,d0
20002DF2: 7365 dc.w 0x7365 ; Invalid opcode
20002DF4: 7276 moveq #118,d1
20002DF6: 6564 bcs.s 0x20002E5C (0x20002e5c) ; 0x20002e5c
20002DF8: 2046 movea.l d6,a0
20002DFA: 6175 bsr.s 0x20002E71 (0x20002e71) ; 0x20002e71
20002DFC: 6C74 bge.s 0x20002E72 (0x20002e72) ; 0x20002e72
20002DFE: 2053 movea.l (a3),a0
20002E00: 7461 moveq #97,d2
20002E02: 7475 moveq #117,d2
20002E04: 7320 dc.w 0x7320 ; Invalid opcode
20002E06: 456E dc.w 0x456e ; Invalid opcode
20002E08: 636F bls.s 0x20002E79 (0x20002e79) ; 0x20002e79
20002E0A: 6469 bcc.s 0x20002E75 (0x20002e75) ; 0x20002e75
#include "common.h"
#include "mcf5xxx.h"
#include
#include "low_level.h"
__interrupt__ void pit0_irq(void)
{//vector 64+55=119, source =55
//take a read from the ADC
unsigned int adc_result; //store adc result here
PIT0_PMR = 0x6000; //reset flag
ADC_CTRL1 |= (113); //start conversion
adc_result = (ADC_ADRSLT0>>3); //read result register
printf("%d\n\r", adc_result);
fflush(stdout);
}
int main()
{
GPIO_DDRTC = 0xff; //init output port
GPIO_PORTTC = 0x00; //init port pins
mcf5xxx_set_handler(64 + 55, pit0_irq); //init irq
//PWM module setup, outputs 1, 3, 5, 7
GPIO_PTDPAR = 0x0f; //pwm outputs on port td
PWM_PWMPOL = 0xaa; //pulses high
PWM_PWMCTL = 0xf0; //concatenate all 4 channels to 16bit
PWM_PWMDTY01 = 0x0010;
PWM_PWMPER01 = 0xffff;
PWM_PWMDTY23 = 0x1000;
PWM_PWMPER23 = 0xffff;
PWM_PWMDTY45 = 0x1000;
PWM_PWMPER45 = 0xffff;
PWM_PWMDTY67 = 0x1000;
PWM_PWMPER67 = 0xffff;
PWM_PWMSCLA = PWM_PWMSCLB = 8;
PWM_PWMCLK = 0xaa; //select scaled clocks
PWM_PWME = 0xaa; //enable all channels
//PIT module setup
PIT0_PCSR = PIT_PCSR_PRE(13)|PIT_PCSR_PIE|
PIT_PCSR_RLD|PIT_PCSR_EN;
PIT0_PMR = 0x6000;
//configure analog to digital converter
ADC_CTRL2 = 3; //clock div assuming fast clock
ADC_ADSDIS = (11); //stop at AN1, only perform sample0 with AN0
ADC_POWER &= ~(0x0001); //power up adc A
GPIO_PANPAR = 1; //setup AN0 to primary pin function
INTC_ICR55 = 0 | INTC_ICR_IP(6) | INTC_ICR_IL(6);
//set priorities for pit0 irq55
INTC_IMRH &= ~INTC_IMRH_MASK55;
//unmask that specific interrupt
mcf5xxx_irq_enable();
while(1)
{
}
}