??? 01/30/06 12:17 Read: times |
#108697 - use gvim Responding to: ???'s previous message |
Using gvim you can post nicely formatted code like so and it genarates the html for you so it couldnt be easier so you get stuff looking like this:-
#include "c:\cvavr\inc\mega128.h" #include "portdef.h" #include "adc.h" extern void serprintstr(char *); extern int systime_ms; /* adc_state is used to store the channel that we are currently reading, * and whether we are still waiting for it or if it's already read. */ ADCState adc_state; int ADCdata[8]; // The actual data we got from the adc int ADCoffsets[8]; // The offset of the accel/gyro int ADCscalingn[8]; // The scaling numerator (multiply by this) int ADCscalingd[8]; // The scaling denominator (divide by this) void ADCinit(void) { EICRB=0x80; // trigger INT7 on falling edge (/INT line of ADC) EIMSK=0x80; DDRE=0x70; // Bits 4,5,6 are outputs adc_state.chan=0; adc_state.waiting=0; ADCCtrlRD = 1; ADCCtrlWR = 1; // 2-4 are gyros, 5-7 are accelerometers ADCoffsets[2]=2096; ADCoffsets[3]=1398; ADCoffsets[4]=1988; ADCoffsets[5]=1160; ADCoffsets[6]=1195; ADCoffsets[7]=1133; ADCscalingn[2]=1; ADCscalingn[3]=1; ADCscalingn[4]=1; ADCscalingn[5]=2; ADCscalingn[6]=2; ADCscalingn[7]=2; ADCscalingd[2]=1; ADCscalingd[3]=1; ADCscalingd[4]=1; ADCscalingd[5]=1; ADCscalingd[6]=1; ADCscalingd[7]=1; } /* Set up a conversion for the next channel. */ void ADCCnvSetup(void) { DisableInterrupts; DDRA = 0xFF; ADCCtrlWR = 0; // Normal operation, internal clock mode, internally controlled acquisition, // 0 to 5V input range PORTA = (0b01000000 + adc_state.chan); ADCCtrlWR = 1; adc_state.waiting=1; EnableInterrupts; } /* When we get an interrupt from the ADC, read in the data */ interrupt [EXT_INT7] void adc_ready(void) { // If we are waiting for a conversion if(adc_state.waiting) { adc_state.waiting=0; DDRA = 0x00; ADCCtrlRD = 0; ADCCtrlHBEN = 0; ADCdata[adc_state.chan]=0x0000; // Read in the low byte ADCdata[adc_state.chan]=PINA; ADCCtrlHBEN = 1; // Read in the high byte ADCdata[adc_state.chan]+=((int)(PINA & 0x0F)) <<8; ADCCtrlRD = 1; // Scale the data ADCdata[adc_state.chan]=ADCdata[adc_state.chan]-ADCoffsets[adc_state.chan]; ADCdata[adc_state.chan]=ADCscalingn[adc_state.chan]*ADCdata[adc_state.chan]; ADCdata[adc_state.chan]=ADCdata[adc_state.chan]/ADCscalingd[adc_state.chan]; adc_state.chan++; } ADCCnvSetup(); } |
Topic | Author | Date |
help | 01/01/70 00:00 | |
Get ready for Thrashing. | 01/01/70 00:00 | |
Clickable Link | 01/01/70 00:00 | |
Not exactly a newbie | 01/01/70 00:00 | |
Help ive fallen down a well | 01/01/70 00:00 | |
after your first post Kalpak posted | 01/01/70 00:00 | |
rtc code PLS HELP | 01/01/70 00:00 | |
Your code | 01/01/70 00:00 | |
PLS help | 01/01/70 00:00 | |
Commented code | 01/01/70 00:00 | |
Comments | 01/01/70 00:00 | |
pls help | 01/01/70 00:00 | |
use gvim | 01/01/70 00:00 | |
Pretty Print | 01/01/70 00:00 | |
a CAPITAL sin | 01/01/70 00:00 | |
rtc code | 01/01/70 00:00 | |
RTC code | 01/01/70 00:00 | |
Your code | 01/01/70 00:00 | |
pls help | 01/01/70 00:00 | |
How to post your code | 01/01/70 00:00 | |
code for rtc | 01/01/70 00:00 | |
Here is the code you require | 01/01/70 00:00 | |
andy | 01/01/70 00:00 | |
The details you require![]() | 01/01/70 00:00 | |
2 accounts? | 01/01/70 00:00 | |
Yes! | 01/01/70 00:00 | |
ds | 01/01/70 00:00 | |
already said! | 01/01/70 00:00 |