Help needed regarding CPU clock

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

Help needed regarding CPU clock

Jump to solution
1,179 Views
simar
Contributor III

Hi there

My question is that how can I know that at what frequency my CPU is running and if I'm using external or internal clock ..

Actually I'm not sure if my circuit contains clock because i don't know how it looks as the components are SMD of which I'm unfamiliar.

 

My basic problem is that I want to write and then read data from EEPROM, I'm using EEPROM bean of processor expert. I can get ERR_OK both from SetByte and GetByte but the value returned is always 255 while i'm passing it 1..

You can look at the code below

void main(void){unsigned char simar = 1;unsigned char return_val; unsigned char* read_data;//volatile unsigned int* address;//  address=(volatile unsigned int*)0x13f000;IEE1_TAddress address;IEE1_TAddress address1,address2,address3;//1306624 - 1310715//address=(IEE1_TAddress)0X13F020;address1=(IEE1_TAddress)0X13F000;address2=(IEE1_TAddress)0X13F000;address3=(IEE1_TAddress)0X13F000;  //unsigned long address   =1310715UL;  /* Write your local variable definition here */  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/  PE_low_level_init();  /*** End of Processor Expert internal initialization.                    ***/  DDRT=0xF0;                // Setting Port T pin 4,5,6,7 as output  return_val = IEE1_EraseEeprom(address1); if(return_val == ERR_OK)  {           LED3=LED_OFF;  }  return_val = IEE1_SetByte(address2,simar);   if(return_val == ERR_OK)  {           LED1=LED_OFF;           return_val=IEE1_GetByte(address3,read_data);                      if(return_val == ERR_OK)           {                    if(*read_data == 1)                    {                              LED2=LED_OFF ;                     }           }  }   //IEE1_TAddress Addr,word Data);  /* Write your code here */  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/  for(;;){}  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

 

I need to use EEPROM urgently, so please help me.

Also I think there should be some idea to get the clock speed from the debugger.

I'm using code warrior and my processor is mc9s12xd256

 

Thanks in advance

Labels (1)
0 Kudos
1 Solution
527 Views
ProcessorExpert
Senior Contributor III
Hello,
  
it is not Processor Expert issue it is rather aplication issue. For more details pleas check enclosed example project created in CW V5.0 and PE V3.01. For more details about EEPROM compoenent including some Typical usage pleas go to the component´s help using "Help" menu command from component´s pop-up menu.
best regards
Vojtech Filip
Processor Expert Support Team

View solution in original post

0 Kudos
4 Replies
528 Views
ProcessorExpert
Senior Contributor III
Hello,
  
it is not Processor Expert issue it is rather aplication issue. For more details pleas check enclosed example project created in CW V5.0 and PE V3.01. For more details about EEPROM compoenent including some Typical usage pleas go to the component´s help using "Help" menu command from component´s pop-up menu.
best regards
Vojtech Filip
Processor Expert Support Team
0 Kudos
527 Views
simar
Contributor III
 unsigned char* read_data;  unsigned char p; read_data = &p;    return_val=IEE1_GetByte(IEE1_AREA_START,read_data);

 

 

This is what the difference is ...

Declared a pointer and make that pointer to point some variable

0 Kudos
527 Views
simar
Contributor III

What I did is this

 

unsigned char* read_data;

 

I have declared a pointer of char type but not initialized it. So may be it take any garbage value. Pointers in C are not automatically assigned memory space. So you can't do simply

 

*read_data =23;

 

This will generate some runtime error.. as it does not know where it write data. It does not point to any memory so it does not have a memory..

 

Only if I do .

unsigned char p;

read_data = &p

 

we have a memory of address &p and pointer read_data where we can write something..

 

0 Kudos
527 Views
none_3710978
Contributor I

Using about 3 to 5 lines of assembler code, you can configure pe4 a an e-clock out pin, and observe both the frequency and quality using a DSO.

 

P&E Microcomputers CASM12 Example Using the MC9S12DP256B.inc header file by Lou Dillard of Motorola 2003 :

 

$include 'MC9S12DP256B.inc'

 

 

 

E-Clock_Monitor_Configuration:

                                bset ddre,ddre4; Configure PE4 as an output pin.

                                 bclr pear,neclk ;  Configure PE4 as e-clock output.                                                            

                                 clr ebictl            ;  Setup PE4 as e-clock output.

 

 

If you add this to your code either as is if you are writing in assembler, or add it as inline assembly using the above inc file as a reference for register locations and bit fields, you will output a buffered and measureable clock on the PE4 pin :smileyhappy:

 

0 Kudos