Forum - MCS Electronics


FAQFAQ SearchSearch RegisterRegister Log inLog in

RTC, context switch and process init?

Post new topic   Reply to topic Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message

Bascom Member

Joined: 02 Apr 2015
Posts: 21

PostPosted: Wed Apr 15, 2015 8:53 pm    Post subject: RTC, context switch and process init? Reply with quote

I have ATXMEGA128A1 with a 32MHz crystal. I need to activate RTC to count for 0.5ms between my debugging program and the main program.
My program = prog 0x000000-0x007FFF, ram 0x002000-0x002FFF, init stack=0x2FFF
Main program (user's program) = prog 0x008000-0x020000, ram 0x003000-0x003FFF, init stack=0x3FFF
While my program is in its waiting for USART mode (not INPUT from BASCOM, but my own function), it should switch to the main program.
I need to store registers R0-R31, RAMPs (D,X,Y,Z,EIND) and SREG to the context because they're all for analysis with my commands. For example, "cpu" command prints the context of the main program. I used to do that on AVR-GCC, but only while my program was completely just a USARTC0_RXC interrupt routine which has disadvantages like how to stop the flow of the main program and receive next input. Next inputs can't be received during the interrupt.
I'm currently using USARTC0's DRE and RXC for input and output buffer which is all built in BASCOM and these two programs mustn't be interrupt routines.

My questions are:
    What values do I need to set for RTC to count 0.5ms? My microcontroller doesn't have a 32kHz crystal so what can I do?
    Is there a source code in BASCOM (either basic or assembler) of an already done context switching between two processes?
    Since I can only initialize the context of only one program during program initialization (which is when it's starting), how do I initialize a stacked up context of the other program while making sure that everything is popped correctly from the stack and RETI'd directly to the entry point of the program?
    How do I split the entry point label into lowbyte, midbyte and highbyte in assembly so I can put them on the stack so that later the CPU can RETI on it and get to it?

(BASCOM-AVR version : )
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum