Problems with Processor Expert and MCS912DG256

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems with Processor Expert and MCS912DG256

3,328 Views
PhattieM
Contributor I
Firstly I am a new user to Codewarrior and PE.  I do however know C.

I am part of a team that is attempting to communicate with 3 devices and output with PWM.

The communication is performed on two SPI interfaces (an accelerometer and a yaw sensor) and also the AN00 ADC device available on chip.

My problems are:
1.  The yaw and accelerometers require 16 bits of data to be sent and recieved with the SS pin low.  When using sendChar its only low (obviously) for the first 8 bits.  When I use sendChar twice the SS is high momentarily before returning to low.  Since I do not have interrupts enabled I cannot use the SendBlock() function and even if I were, it appears that the data still will not  be clocked correctly.  Can someone advise me either with a code segment or a setting that can be changed?

2. The ATD is NOT working.  Its very simple really, I am using the ATD on pin AN00 and I am applying a signal to the correct pin (and my grounds are tied together).  In fact, I have an eval board that uses the MC9S12DT256 and it still does not communicate even when checking the pins listed on the user guide.  The problem is when stepping through  with the debugger, the measurement is attempted but the atd_stat? register is never cleared/set whatever when its waiting for the measurement.  This is the same with interrupts disabled.  This really should not be hard to do.  Can anyone advise me to proper settings perhaps?   I think that there is something wrong with PE because Im getting identical results on my board and the eval board.

This has brought my project to a halt and I'm at the final week :eek:

Thanks much in advance,
Mark

Labels (1)
0 Kudos
Reply
2 Replies

684 Views
PhattieM
Contributor I
    Thanks for the replies but nothing appears to be working.  I've removed the SPI bean and replaced it with the SPI Init bean (to offer more control). Here's the initialization code: (generated by PE).  This will show you the settings.

Code:
//Init code generated by PEvoid Accelerometer_Init(void){/* Control register 2 setting */  /* SPI1CR2: MODFEN=1 */  setReg8(SPI1CR2, 16);                 /* Frequency setting */  setReg8(SPI1BR, 0);                   /* Control register 1 setting */  /* SPI1CR1: MSTR=1,SSOE=1 */  setReg8(SPI1CR1, 18);                 }//bigmac's send code//************************************************//*//*  This method sends a character across the SPI//*  interface. It returns the last read value.//*//************************************************Byte1 Accelerometer_SendChar(Byte1 data){    while (!SPI1SR_SPTEF); /* Wait for Tx buffer empty */  SPI1DR = data;  while (!SPI1SR_SPIF);  /* Wait for Rx buffer full */  return SPI1DR;}//My register init code//************************************************//*//*  This method uses the SPI interface to //*  initialize the Left and Right Accelerometers.//*//************************************************void Set_ControlRegisters_Accel(void){    //Word data structure  Byte1 send_data1, send_data2;    //Top 4 Bytes: Writing to Address for CTRL_Reg_1;  //Bot 4 Bytes: Data to set the CTRL_Reg_1.  send_data1 = 0x60;  send_data2 = 0xC4;    SPI1CR1_SSOE = 0;    //Send the data across the SPI interface.  (void)Accelerometer_SendChar(send_data1);  (void)Accelerometer_SendChar(send_data2);    SPI1CR1_SSOE = 1;    //Top 4 Bytes: Writing to Address for CTRL_Reg_2;  //Bot 4 Bytes: Data to set the CTRL_Reg_2.  send_data1 = 0x61;  send_data2 = 0x80;    SPI1CR1_SSOE = 0;      //Send the data across the SPI interface.  (void)Accelerometer_SendChar(send_data1);  (void)Accelerometer_SendChar(send_data2);    SPI1CR1_SSOE = 1;     //Control Register 3 only deals with highpass filter  }
I'm also including links to the datasheets for both the yaw and accelerometers.  TIA for your help.
Accelerometer
Yaw
 

~Mark




Message Edited by PhattieM on 2007-05-10 06:55 PM

Message Edited by PhattieM on 2007-05-10 06:55 PM
0 Kudos
Reply

684 Views
bigmac
Specialist III
Hello Mark,
 
To answer your first problem regarding the external SPI devices, you will need to allocate a GP output for SS use (rather than automatically generated SS signal), and control this to suit the peripherals.  You will also need to match the CPHA and CPOL settings to suit each peripheral device.  In all probability, you would not use PE for the SPI interface code so as to gain more flexibility, and simplify the resulting code.
 
Do a search of these forums, and you should find many examples of SPI master usage to communicate with various external devices.
 
I cannot help with your ATD problem.
 
Regards,
Mac
 
0 Kudos
Reply