Problem with NE64 Interrupts

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem with NE64 Interrupts

1,652 次查看
jbieber
Contributor I
I'm trying to program a keypad (standard grayhill 4x4 matrix) with a DEMO9S12NE64.  I'm not using an encoder - I just wrote a simple function in C that checks each row to see if it has been asserted, then checks to see if the column is asserted (through a counter).  I wrote a timer interrupt to assert each column.  I used the following code to configure the timer.
 
  TSCR1 = 0x80; //enable timer
  TCTL1 = 0x00;
  TIOS = 0xF0;//Timer channels 4 - 7 act as output compare
  TIE = 0x40; //enable standard timer interrupt on Channel 6
  TSCR2 = 0x0E; //enable timer overflow & timer reset interrupts
I wrote the interrupt in main:
  
   interrupt void HandleTimerInterrupt(void)
 
Then added the appropriate entry in Vectors.c:
 
  HandleTimerInterrupt,                 /* 49 Default Timer CH6 interrupt FFE2*/
 
I configured the pins (on Port J) that I'm using for the columns using DDRJ (setting those that are being used for the columns as low)
 
I'm not sure what I'm missing, this interrupt never polls the columns, so I can't get anything out of my keypad!
 
(I'm new to MCU programming, so any help is greatly appreciated!)
 
Thanks!
标签 (1)
0 项奖励
回复
1 回复

776 次查看
mjbcswitzerland
Specialist V
Hi

Please see the following post for an example of a periodic interrupt using a PIT rather than a 16 bit timer:
http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&message.id=3653

Below is code which uses output compare 7 to generate an interrupt after a delay (msDelay ) which is used in the uTasker project. By comparing with what you have done so far you may find the reason why yours is not working correctly.

TSCR2 = (BUS_CLOCK_128 | TCRE);                                      // Bus clock / 128
TIOS = (IOS7);                                                       // enable output compare
TC7_HI = TCNT_HI;                                                    // cause match to reset counter
TFLG1 = C7F;                                                         // Reset interrupt request flag
TC7_HI = msDelay * ((BUS_CLOCK / 128 / 1000));   // set ms unit compare rate (max is 167ms)
TTIE = C7I;                                                          // enable interrupt
TSCR1 = TEN;                                                         // enable timer

You may also like to take a look at the uTasker project for the NE64 (it is available as GNU, Codewarrior and IAR project set up). It includes everything required for matrix keyboards (you can set a define for the number or rows and columns and for which ports are used as input and scan output and the program does the rest) as well as an operating system, TCP/IP stack, LCD control etc. The uTasker simulator simulates the NE64 and these peripherals - you can simply add a Bitmap drawing of your keypad and it will immediately allow you to simulate with the grayhill keypad displayed on your PC (click on the keys with your mouse and see the scanning routine detect it, etc...).

Get all info from the web site below. The project is free for educational, hobby and other non-commercial use. It is used in a number of schools and universities for teaching purposes and is probably the best way to get up to speed with the NE64 - you can have your key pad working, which will for example send emails telling you which button has been pressed, all in an afternoon.

Best regards

Mark

www.uTasker.com


0 项奖励
回复