I’m trying to do an interrupt with an interval of 26µs. With the 16MHz oscillator and the right timerA settings the TCA register counts up every 0.5µs till TCA equals 0xFF.
Is there a way to initialize TCA with 0xCB to get my 26µs interval? At the moment i just get an interval of 127.5µs.
Thanks a lot, it works. Now I get my 26µs interrupts.
At the moment I’m trying to use global variables, but it won’t work. I have been trying it for a week. If i just toggle a pin in my interrupt routine, I get a square signal. If i toggle a global variable in my main routine, and write it on my pin in the interrupt routine it doesn’t work.
I implemented in my interrupt.c
extern “C” {
extern int tx_intr;
extern int send_digit;
}
and defined global in my main.c
extern “C” {
int tx_intr=0;
int send_digit=0;
}
I also toggled the variable(send_digit) in the interrupt routine and then wrote it on the pin… this works.
It has been awhile since I did C code on the Bap as I get most of C fix with Arduino
Awhile ago, I did play with it for quite awhile and started to build a C support library that provided a lot of the same functionality as the Basic did. Some things were working better than others, but I did have a version of the Phoenix code running on it as well as a Brat. More details (including zip file with code) in the thread: viewtopic.php?t=6677&p=70050#p70050
I don’t see anything obvious, my TimerA interrupt looks like:
extern "C" void TIMERAV() __attribute__ ((interrupt_handler));
extern "C" void TIMERAV()
{
lTimerCnt += 256; // increment our counter TCA is the low order byte so increment past it...
IRR1.BIT.IRRTA = 0; // clear out the overflow flag
}
My next step would be to look at list and map files to see what variable names were generated and see if they were resolved to the same one… Your extern “C” brackets should handle that for C++. If I get a chance I map play around and see if I see anything else.
Is it possible, that the hitachi isn’t fast enough? The interrupts activate every 26µs. Toggling a pin in main needs 2,2µs. I don’t know how many instructions are needed to jump out of the interrupt routine but if it don’t happens within 26µs it interrupts itself.
I have read all your code, it helped me a lot but I’m not a pro. I keep on trying and reading and hope there will be a breakthrough soon.
The whole problem is:
I just want to send an UART signal with 38,4 kBaud. I also tried to use the SCI3 interface, but I can’t see anything on my TxD pin.
I have not seen all of your code, so I am only guessing. Are you using the overflow for the interrupt or are you using a compare match A for the interrupt?
But I am guessing that you are using Compare Match A. So I don’t know what you are generating by the statement: CMFA=0;
If you are using the same type of definition files, like I have used (3694s.h), I would expect to see something like:
TV.BIT.CMFA = 0;
If the appropriate bit is not cleared in the register, the interrupt handler will be called in an endless loop. If you are configured for overflow, then the above should be changed to:
TV.BIT.OVF = 0;
If you are using compare match, I don’t know if you configured TCRV0 to clear the TCNTV on a match or not or if you need to zero it in your interrupt handler.
Hey I’m still trying to work with global variables, but I have no idea what I should try next.
Maybe someone may take a look on my code and can help me.
The interrupt works, but I’m not able to count the interrupts.
It’s doing nothing on Pin15 (Botboard Pin8)