Hi,
I have a problem.I must send through the serial port the number 1 and the number 0 every second using a timer of the c167cs. Would someone know me to help?
Thanks a lot. Monday I will try it to the university and I will make you know. Thanks still for the help!
Here is an extremely basic program that does what you ask. Perhaps this helps to get you started as you will surely need to modify it.
#include "c167cs.h" #include "intrins.h" void GPT1_viTmr3(void) interrupt 0x23 { S0TBUF = '0'; S0TBUF = '1'; /* allowed since the register is double buffered */ P2 ^= 0x0001; /* toggle P2.0 */ } void main(void) { /* setup the serial port */ S0BG = 0x0040; /* 9.600 kbaud @ 20 MHz clock */ S0CON = 0x0011; /* format: 8-N-1 */ /* P3.10 is used for TxD and P3.11 is used for RxD */ _bfld_( P3,0x0C00,0x0400); /**/ _bfld_(DP3,0x0C00,0x0400); /* set data direction */ S0CON |= 0x8000; /* enable baud rate */ /* use GPT1 for the 1 second time base */ T3CON = 0x0087; /* clock tick is 51.2 usec, count down */ T3 = 0x4C4B; /* 1 second load value */ T2CON = 0x0027; /* t2 reloads T3 on the interrupt */ T2 = 0x4C4B; T3IC = 0x004B; /* set up the interrupt level and enable it */ T3R = 1; /* start timer 3 running */ DP2 = 1; /* toggle P2.0 every second */ IEN = 1; /* globally enable interrupts */ for(;;){}; }
Hope this helps. -Chris
Have you ever done any programming at all?
No unfortunately no. I have never used a Microcontroller. This problem has been assigned me and I doesn't know whether to resolve it. Could you help me?
Do you know how to use the C167's serial port?
Do you know how to use a timer on the C167?
View all questions in Keil forum