Hi everyone. I need your help to solve this issue. I am using a XC164CS microcontroller to run an aplication. The next aplication code toggles a P9.0 pin every 8 seconds.
#include <XC164.h> #define T2INT 0x22 #define GPT1_TIMER_2 2 sbit led = P9^0; void GPT1_vInit(void); void MAIN_vUnlockProtecReg(void); unsigned char second; void main (void) { MAIN_vUnlockProtecReg(); // unlock write security PLLCON = 0x7D54; // load PLL control register GPT1_vInit(); // initialize Timer 2 PSW_IEN = 1; DP9 = 0x0001; // load direction register while(1); } void GPT1_viTmr2(void) interrupt T2INT using RB_LEVEL15 { second++; if(second == 8) { second = 0; led =! led; } GPT12E_T2 = 0x8170; // load timer 2 register to interrupt every 1 sec }
When I declare unsigned char idata the "second" variable, the application works properly. (This variable is alocated in on chip ram). However if i just declare unsigned char (external memory) the appliction doesn't work. The pin doesn't toggle. I have off-chip SRAM connected through an 16 bit multiplexed bus. Below I show you some configuration and setup.
What could be the problem? Thank you very much.
subefotos.com/.../
How is the HOLD compiler directive being used? http://www.keil.com/support/man/docs/c166/c166_hold.htm This can affect where smaller variables are stored.
Experiment by modifying the HOLD directive, using #pragma HL or explicitly using "xhuge" in the variable declaration.
What happens if the variable is initialized (second = 0;)?
Hello Zack. Thanks for your reply. I'm desperate. I have tried with your two solutions, but it was useless. I have thinking that the problem would be into hardware, but the XC16x board seems ok. I tried rising RAM timings too and now I don't know what more I have to do. Any idea to attempt solve this problem? If you need any information I will give you. Thank you very much.
Hello Here you have an aditional information of my board. It seems that the access for write and read in my external RAM is possible.