More progress. I realised that, with the timing accuracy of the last test, there's really no need to use pulse-widths to transmit the data, it can just be bit-banged directly, as long as the start bit is synchronised beforehand (the slave will sample in the middle of each bit).
_SetHPTimerAfterTimeout(0,master_wait_untill,master_send_bit,master_send_bit,0);
It's been quite a while, but IIRC for direct bit-banging you need to be able to sample at about 8x the bit speed for a reliable bit banging UART receiving an 8 bit byte. So using the HP timer running at 1mSec means 8mSec/bit.
where do you place your code for void master_send_bit()? And where do you call it from?I mean what is the start action in the master to send the data to teh slave?
void init_LED_flasher(){ if (start_LED_flasher) { start_LED_flasher = 0; master_begin_transmission(); }}int master_current_bit = 0;int master_wait_untill = 65536;void master_send_bit();void master_begin_transmission();void master_begin_transmission_();unsigned short master_message_buffer = 54321; //Just a random number at the momentvoid __attribute__((optimize("O0"))) master_begin_transmission(){ while (*(int*)0xc0242014 > 1024) { //wait till it's at the start, wrap will coded later } *((volatile int *) AF_LED_ADDRESS) = LED_ON; //Signal slave which will check every 10ms or so _SetHPTimerAfterTimeout(0,master_wait_untill,master_begin_transmission_,master_begin_transmission_,0); master_wait_untill+=1024;}void master_begin_transmission_(){ *((volatile int *) AF_LED_ADDRESS) = LED_OFF; //Signal slave, which will wait 1536uS before starting to sample the bits _SetHPTimerAfterTimeout(0,master_wait_untill,master_send_bit,master_send_bit,0);} void master_send_bit(){ if (master_message_buffer & (1 << master_current_bit)) //get the current bit { *((volatile int *) AF_LED_ADDRESS) = LED_ON; } else { *((volatile int *) AF_LED_ADDRESS) = LED_OFF; } if (master_current_bit < 16) //16 bits for now { master_current_bit++; master_wait_untill+=1024; _SetHPTimerAfterTimeout(0,master_wait_untill,master_send_bit,master_send_bit,0); } else { master_wait_untill = 65536; //set it back to how it was before start_LED_flasher = 1; //allow it to run again }}
Yesterday my new oscilloscope arrived. If my 7 years old daughter will let me at the easterdays I will find some time to go ahead with my mikcorcontroller to steer the S110 project.
What are the parameters of _SetHPAfterTimeout and why two times master_send_bit as callback are entered here, what does the last 0 mean?
The HP Timer stuff in which trunk is it? What HP timer functions are available, I remember in one thread there were few?
extern int _SetTimerAfter(int delay, int(*good_cb)(int, int), int(*bad_cb)(int, int), int whatever);extern int _SetTimerWhen(int time, int(*good_cb)(int, int), int(*bad_cb)(int, int), int whatever);extern int _CancelTimer(int);extern int _SetHPTimerAfterNow(int delay, int(*good_cb)(int, int), int(*bad_cb)(int, int), int whatever);extern int _SetHPTimerAfterTimeout(int time_base, int delay, int(*good_cb)(int, int), int(*bad_cb)(int, int), int whatever);extern int _CancelHPTimer(int);
NHSTUB(SetTimerAfter, )NHSTUB(SetTimerWhen, )NHSTUB(CancelTimer, )NHSTUB(SetHPTimerAfterNow, )NHSTUB(SetHPTimerAfterTimeout, )NHSTUB(CancelHPTimer, )
What oscilloscope did you get?
QuoteWhat are the parameters of _SetHPAfterTimeout and why two times master_send_bit as callback are entered here, what does the last 0 mean? See here. The last zero doesn't mean anything, apparently it doesn't do anything.
That parameter (named 'whatever') is what the timer callbacks will get as second parameter (it will be passed unchanged). It can help if you re-use the same timer callback function.
Oh, and for some reason the S110 doesn't like its HP timers running with too short a delay, which was what caused a lot of problems when trying to write the transmission code originally. Though this shouldn't be a problem with the attached code.
Quote from: Recyclojunk64 on 20 / April / 2014, 14:41:15Oh, and for some reason the S110 doesn't like its HP timers running with too short a delay, which was what caused a lot of problems when trying to write the transmission code originally. Though this shouldn't be a problem with the attached code.If you can be more specific about the symptoms and "too short a delay" that might be helpful for people who want to do this kind of thing in the future.
Started by fudgey General Discussion and Assistance
Started by srsa_4c « 1 2 » General Discussion and Assistance
Started by lipefrs « 1 2 » Script Writing
Started by reyalp DryOS Development
Started by reyalp General Discussion and Assistance