mikea
New Member
Posts: 2
|
Post by mikea on Nov 30, 2016 15:02:37 GMT
Hi,
I have an application developed that uses an arduino mega but I have ran out of processing power, so I am considering a 32 bit processor instead. Rather than use the librarys for digital read and write I use the ports directly as I am transferring bytes, not bits. My App also uses the timers for clock generation, some for external use some for interrupts and I need ISRs to attach to these interrupts. Where can I get the information to enable me to check that the timers etc are usable and to convert my programme?
|
|
|
Post by ptqfp144 on Nov 30, 2016 23:16:27 GMT
|
|
|
Post by mjb on Dec 1, 2016 9:19:46 GMT
Hi, Do you need to read 8 port lines in a single operation? This possible on TC275 Port00 on the J406 connector. Here is a demo sketch:
/*** Don't worry, the normal Arduino setup() and loop() are below this block! ***/
/* LMU uninitialised data */ StartOfUninitialised_LMURam_Variables /* Put your LMU RAM fast access variables that have no initial values here e.g. uint32 LMU_var; */ EndOfUninitialised_LMURam_Variables
/* LMU uninitialised data */ StartOfInitialised_LMURam_Variables /* Put your LMU RAM fast access variables that have an initial value here e.g. uint32 LMU_var_init = 1; */ EndOfInitialised_LMURam_Variables
/* If you do not care where variables end up, declare them here! */
volatile uint8 Port00_Sample = 0; uint32 volatile PinIntFunc2_var = 0;
void ReadPort00(void); void PinIntFunc2(void);
/*** Core 0 ***/
void setup() { // put your setup code for core 0 here, to run once:
/* Call a function every 100us */ CreateTimerInterrupt(ContinuousTimerInterrupt, 10000, ReadPort00);
/* Any change on Pin D2 will call the PinIntFunc2 function */ attachInterrupt(2, PinIntFunc2, CHANGE); }
void loop() { // put your main code for core 0 here, to run repeatedly:
}
/* Entered when pin D2 changes state */ void PinIntFunc2(void) {
PinIntFunc2_var++;
}
/* Entered every 100us */ void ReadPort00(void) {
/* Read directly Port00 bit 0 to 7. This is J406 PIN25 to PIN39 */ Port00_Sample = (uint8)P00_IN.U;
}
/*** Core 1 ***/
/* CPU1 Uninitialised Data */ StartOfUninitialised_CPU1_Variables /* Put your CPU1 fast access variables that have no initial values here e.g. uint32 CPU1_var; */ EndOfUninitialised_CPU1_Variables
/* CPU1 Initialised Data */ StartOfInitialised_CPU1_Variables /* Put your CPU1 fast access variables that have an initial value here e.g. uint32 CPU1_var_init = 1; */ EndOfInitialised_CPU1_Variables
void setup1() { // put your setup code for core 1 here, to run once:
}
void loop1() { // put your main code for core 1 here, to run repeatedly:
}
/*** Core 2 ***/
/* CPU2 Uninitialised Data */ StartOfUninitialised_CPU2_Variables /* Put your CPU2 fast access variables that have no initial values here e.g. uint32 CPU2_var; */ EndOfUninitialised_CPU2_Variables
/* CPU2 Initialised Data */ StartOfInitialised_CPU2_Variables /* Put your CPU2 fast access variables that have an initial value here e.g. uint32 CPU2_var_init = 1; */ EndOfInitialised_CPU2_Variables
void setup2() { // put your setup code for core 2 here, to run once:
}
void loop2() { // put your main code for core 2 here, to run repeatedly:
}
|
|
mikea
New Member
Posts: 2
|
Post by mikea on Dec 2, 2016 14:40:49 GMT
Hi,
thanks for the example. I see there are references to the various interrupt functions in the user manual, but not to the names of the ports. Also the 'createinterrupt' functions have arguments as examples, but no definitive list or explanations. There is an assumption that the 'create timer interrupt' function will drive pin 2; where is this defined and what choices do I have? E.G can I create a timer interrupt on compare as I can on the mega ('ISR(TIMER0_COMPA_vect') and not use an external pin?
'Port00_Sample = (uint8)P00_IN.U;' in your example reads the Port00 lines but where did you get the information to know that P00_IN.U references the port?
What I am looking for is a detailed h/w and s/w manual that will detail the functionality so I can program the chip directly without using the arduino functions.
regards
Mike
|
|
|
Post by mjb on Dec 2, 2016 14:57:42 GMT
Hi, The CreateTimerInterrupt() functions are not tied to any pin. E.g. CreateTimerInterrupt(ContinuousTimerInterrupt, 10000, STM0_inttest); This means: Every 10000 * 0.01us call the function STM0_inttest. CreateTimerInterrupt(OneShotTimerInterrupt, 10000, STM0_inttest); This means: call the function STM0_inttest in 10000 * 0.01us and do not call it again. The CreateTimerInterrupt() is actually creating an interrupt compare event between STM0_TIM0 timer and STM0_CMP1 compare register (the SMT0_CMP0 is used as a timebase for the millis(), micros() and delay()) The Arduino attachInterrupt() function is implemented and Arduino pins 2, 3, 15, 18, 20, 52 can be used. This is unrelated to CreateTimerInterrupt(). The TC275 ports are referred to as "Pxx_IN.U" and "Pxx_OUT.U". You can see from the user manual how the TC275 ports are connected to the Arduino connectors. You can make bit accesses with Pxx_IN.B.P0, Pxx_IN.B.P1 etc. If you want the full TC275 user manual, you need to register at www.infineon.com under "Myinfineon". It is about 28MB!
|
|