Hello,
at first i have to say that i am german so please forgive me that simple English;)
To my problem:
I do not understand Timer which i can use with the Portcounter. (Yes i had read the manual)
I want to create BREAK which goes 88us, than MAB which goes 8 us and at last a StartBit which takes 4us.
#define BIT_RATE 250000 //rate
#define BIT_TIME XS1_TIMER_HZ / BIT_RATE // So i got 4us BIT_TIME
unsigned count;
oled <: 0 @ count; // The oled Port gets a zero an time gets the portcounter value
//BREAK
count += BIT_TIME*22; //my thought: 4us * 22 = 88us.
oled @ count <: 1;
//MAB
count += BIT_TIME*2; // my thought: 4 us *2 = 8us
oled @ count <: 0;
//STARTBIT
count += BIT_TIME;
oled @ count <: 1;
}
The BREAK works but with the MAB i got my problems. I do not know why but in the waveform its not there, after the BREAK is directly the STARTBIT. What is wrong?
Thanks
Greez Paco
@ Timer
-
- XCore Legend
- Posts: 1274
- Joined: Thu Dec 10, 2009 10:20 pm
Maybe your code makes this:
But perhaps you need this:
?
Code: Select all
x___________----_--x
Code: Select all
x_---------------__--_x
-
- XCore Expert
- Posts: 966
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
Please don't confused timers with port counters.
The latter are 16 bit, timers are 32 bit.
The latter are 16 bit, timers are 32 bit.
-
- Member
- Posts: 8
- Joined: Thu Apr 11, 2013 7:25 pm
Sorry, my mistake.
I give up trying to mulitplikate the BIT_TIMER instead of that i use a for-loop which works quit good. Only my StopBit which shall be 8us don't work. It seems like its overwritten by the new loop:S? ( BIT_TIME creates a 4 us Time)
Is there Anything i so wrong? Or something i have to know about the Port Counter? In can't find any help for my Problem in the Descriptions on the Page...
I would be glad if someone can help ..
Code: byte = 0b00110101
void seriByte(out port txd, int byte , unsigned time){
int z;
txd <:0 @ time;
for( z=0; z<22; z++){
time += BIT_TIME; //BREAK
txd @ time <: 0;
}
time += BIT_TIME; //MAB
txd @ time<: 1;
time += BIT_TIME; //HOLD
txd @ time<: 1;
time += BIT_TIME; //STARTBIT
txd @ time <: 0;
for (z = 0; z < 8; z++) { //DATA-BITS
time += BIT_TIME;
txd @ time <: >> byte;
}
time += BIT_TIME; //STOPPBITS
txd @ time<: 1;
time += BIT_TIME;
txd @ time<: 1;
}
I give up trying to mulitplikate the BIT_TIMER instead of that i use a for-loop which works quit good. Only my StopBit which shall be 8us don't work. It seems like its overwritten by the new loop:S? ( BIT_TIME creates a 4 us Time)
Is there Anything i so wrong? Or something i have to know about the Port Counter? In can't find any help for my Problem in the Descriptions on the Page...
I would be glad if someone can help ..
Code: byte = 0b00110101
void seriByte(out port txd, int byte , unsigned time){
int z;
txd <:0 @ time;
for( z=0; z<22; z++){
time += BIT_TIME; //BREAK
txd @ time <: 0;
}
time += BIT_TIME; //MAB
txd @ time<: 1;
time += BIT_TIME; //HOLD
txd @ time<: 1;
time += BIT_TIME; //STARTBIT
txd @ time <: 0;
for (z = 0; z < 8; z++) { //DATA-BITS
time += BIT_TIME;
txd @ time <: >> byte;
}
time += BIT_TIME; //STOPPBITS
txd @ time<: 1;
time += BIT_TIME;
txd @ time<: 1;
}