• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::

論壇索引


Board index » All Posts (albertyoun)




Re: 请教watch dog 怎么用?
#1
新會員
新會員


setup_wdt(WDT_2304MS);在一个函数中只能使用一次吗??
另外,我想延迟10秒,但要使用看门狗,要清看门狗5词以上吗?其他有什么好的办法实现呢??

發表於: 2006/11/9 9:02
頂部


Re: 请教watch dog 怎么用?
#2
新會員
新會員


谢谢...
那restart_wdt();在一个函数中可以多次使用吗?
在子函数也可以多次使用吗?
另外,我今天实际测试,其实reset的精确时间是2060ms,而不是标明的2304 ms,希望大家注意!

發表於: 2006/11/8 18:01
頂部


请教watch dog 怎么用?
#3
新會員
新會員


#fuses WDT // PCB/PCM example

// See setup_wdt for a PIC18 example

main() {

setup_wdt(WDT_2304MS);//是2304ms后reset吗? 这个精确吗?

while (TRUE) {

restart_wdt(); //这句有什么作用????

perform_activity();

}

}

發表於: 2006/11/8 15:34
頂部


Vdd Vss Vpp???
#4
新會員
新會員


大家都知道Vdd and Vss接电源和地.

但是向大家请教,Vdd and Vss的英文缩写是什么?

Vdd--Voltage d??? d???

Vss--Voltage s?? s??

Vpp--?????

It is simple ,But I am sure most of us donot kown the reason~~~~~~

Can any guy be kind to give us the answer?

發表於: 2006/11/6 16:08
頂部


Re: about printf and ccs-c
#5
新會員
新會員


有人有 Embedded C Programming and the Microchip PIC by Richard H. Barnett 吗??
我已经找到第一本了 ........

發表於: 2006/11/6 16:05
頂部


Re: about printf and ccs-c
#6
新會員
新會員


dear mechwu..I just find you are a university teacher......and the article I post is written by you ....what a lucky!!
I am a beginner of ccsc, but have interest to learn it well..maybe I will ask you some questions and firstly thank you for your enthusiam ,spirit of sharing and help.
may I ask you a question?
do you have the two ebooks below?If having ,can you tell me and pass them to me ?
1.PICmicro MCU C: An introduction to Programming the Microchip PIC in CCS C (Spiral-bound)
by Nigel Gardner
2. Embedded C Programming and the Microchip PIC by Richard H. Barnett
Thanks again

發表於: 2006/10/31 18:15
頂部


Re: about printf and ccs-c
#7
新會員
新會員


谢谢mechwu,我按着您的提示做,可以看到输出,但是输出全是乱码,我的com port, baud rate 设置为:com 1, 115200.请教怎么解决.谢谢.
乱码如下:
B<’a˜Â¼Ra¼Òa£”Y뉔үÒ¯v¼ÒR C
8$$<5$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$<$aB<$aB<aY//B<<<<<<
<<<<<<<<<<<<<B<R$/$//B B<Y/////////////
////////////////////////////////////////
//FB<+B<++R£/$//B<%B%BB<BYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
F<KN"B<KKR#/$///////////////////////////
/////////////////////////////+aKaB<KaY//
////////////////////////////////////////
//////////////FB<R$B<RR$5$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
F&"B<&B<&QG/////////////////////////////
//////////////////////////R<RB<$5$$FQ8/

發表於: 2006/10/30 15:21
頂部


Re: 請教有關"Timer"的設定....
#8
新會員
新會員


如何讀取 16 位元的 TIMER1 的數值?有三種讀法,其中已上面那篇的習慣的寫法會百中錯一,很難發現,就算你用線上調試也一樣!

#include <16F877.H>

#use delay(clock = 20000000)
#use rs232( baud = 115200, xmit = PIN_C6, rcv = PIN_C7 )

#define TMR1 *(int16 *)(0x0E) // 定義 TMR1 為位於 0x0E 的 16 bit 變數
#define TMR1L *(int8 *)(0x0E) // 若寫成 *(0x0E) 的話,變成 8 bit !
#define TMR1H *(int8 *)(0x0F)

long Timer_1;
#byte Timer_1 = 0x0E
#byte Timer_1_L = 0x0E
#byte Timer_1_H = 0x0F

#bit A4 = 0x05.4
#bit TRISA4 = 0x85.4

#org 0x0800
void main()
{
int16 t_1, t_2, t_3; int8 i = 0;

setup_timer_1 ( T1_INTERNAL | T1_DIV_BY_8 ); // 1.6 usec per count

TRISA4 = 0;

while(1)
{
A4 = 1; // 用示波器看 pin_RA4 的信號,要加提昇電阻!

t_1 = TMR1; // 這種寫法會有 隨機的 錯誤! 小心喔!
t_2 = Timer_1;
t_3 = get_timer1();

A4 = 0;

if ( ((t_2-t_1)>3) || ((t_3-t_1)>3) || ((t_3-t_2)>3) ) // 抓到蟲啦
{
printf ( "i, t_1, t_2, t_3 = %3u 0x%04LX 0x%04LX 0x%04LX\r\n",
++i, t_1, t_2, t_3 );

t_1 = TMR1; // 這次絕對不會錯!
t_2 = Timer_1;
t_3 = get_timer1();

printf ( "i, t_1, t_2, t_3 = %3u 0x%04LX 0x%04LX 0x%04LX\r\n\n",
i, t_1, t_2, t_3 );
}
}
}

小弟的一點經驗,希望能讓 CCS 新手快樂向前行

祝 順心
~~~~~~~~~~~~~~~~~~~~~~~
以上是转贴,希望对关于timer1读写有帮助
我的问题是,我怎么能看到printf输出---- printf ( "i, t_1, t_2, t_3 = %3u 0x%04LX 0x%04LX 0x%04LX\r\n\n",
i, t_1, t_2, t_3 );

發表於: 2006/10/27 16:38
頂部


Re: about printf and ccs-c
#9
新會員
新會員



如何讀取 16 位元的 TIMER1 的數值?有三種讀法,其中已上面那篇的習慣的寫法會百中錯一,很難發現,就算你用線上調試也一樣!

#include <16F877.H>

#use delay(clock = 20000000)
#use rs232( baud = 115200, xmit = PIN_C6, rcv = PIN_C7 )

#define TMR1 *(int16 *)(0x0E) // 定義 TMR1 為位於 0x0E 的 16 bit 變數
#define TMR1L *(int8 *)(0x0E) // 若寫成 *(0x0E) 的話,變成 8 bit !
#define TMR1H *(int8 *)(0x0F)

long Timer_1;
#byte Timer_1 = 0x0E
#byte Timer_1_L = 0x0E
#byte Timer_1_H = 0x0F

#bit A4 = 0x05.4
#bit TRISA4 = 0x85.4

#org 0x0800
void main()
{
int16 t_1, t_2, t_3; int8 i = 0;

setup_timer_1 ( T1_INTERNAL | T1_DIV_BY_8 ); // 1.6 usec per count

TRISA4 = 0;

while(1)
{
A4 = 1; // 用示波器看 pin_RA4 的信號,要加提昇電阻!

t_1 = TMR1; // 這種寫法會有 隨機的 錯誤! 小心喔!
t_2 = Timer_1;
t_3 = get_timer1();

A4 = 0;

if ( ((t_2-t_1)>3) || ((t_3-t_1)>3) || ((t_3-t_2)>3) ) // 抓到蟲啦
{
printf ( "i, t_1, t_2, t_3 = %3u 0x%04LX 0x%04LX 0x%04LX\r\n",
++i, t_1, t_2, t_3 );

t_1 = TMR1; // 這次絕對不會錯!
t_2 = Timer_1;
t_3 = get_timer1();

printf ( "i, t_1, t_2, t_3 = %3u 0x%04LX 0x%04LX 0x%04LX\r\n\n",
i, t_1, t_2, t_3 );
}
}
}

小弟的一點經驗,希望能讓 CCS 新手快樂向前行

祝 順心
~~~~~~~~~~~~~~~~~~~~~~~
以上是转贴,希望对关于timer1读写有帮助
我的问题是,我怎么能看到printf输出---- printf ( "i, t_1, t_2, t_3 = %3u 0x%04LX 0x%04LX 0x%04LX\r\n\n",
i, t_1, t_2, t_3 );
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
我查阅了ccsc相关资料.......供参考



PRINTF( )
FPRINTF( )

--------------------------------------------------------------------------------



Syntax:
printf (string)

or

printf (cstring, values...)

or

printf (fname, cstring, values...)

fprintf (stream, cstring, values...)



Parameters:
String is a constant string or an array of characters null terminated. Values is a list of variables separated by commas, fname is a function name to be used for outputting (default is putc is none is specified). Stream is a stream identifier (a constant byte)



Returns:
undefined



Function:
Outputs a string of characters to either the standard RS-232 pins (first two forms) or to a specified function. Formatting is in accordance with the string argument. When variables are used this string must be a constant. The % character is used within the string to indicate a variable value is to be formatted and output. Longs in the printf may be 16 or 32 bit. A %% will output a single %. Formatting rules for the % follows.



If fprintf() is used then the specified stream is used where printf() defaults to STDOUT (the last USE RS232).



Format:

The format takes the generic form %nt. n is optional and may be 1-9 to specify how many characters are to be outputted, or 01-09 to indicate leading zeros, or 1.1 to 9.9 for floating point and %w output. t is the type and may be one of the following:

c
Character

s
String or character

u
Unsigned int

d
Signed int

Lu
Long unsigned int

Ld
Long signed int

x
Hex int (lower case)

X
Hex int (upper case)

Lx
Hex long int (lower case)

LX
Hex long int (upper case)

f
Float with truncated decimal

g
Float with rounded decimal

e
Float in exponential format

w
Unsigned int with decimal place inserted. Specify two numbers for n. The first is a total field width. The second is the desired number of decimal places.




Example formats:

Specifier
Value=0x12
Value=0xfe

%03u
018
254

%u
18
254

%2u
18
*

%5
18
254

%d
18
-2

%x
12
fe

%X
12
FE

%4X
0012
00FE

%3.1w
1.8
25.4


* Result is undefined - Assume garbage.



Availability:
All Devices



Requires:
#use rs232 (unless fname is used)



Examples:
byte x,y,z;

printf("HiThere");

printf("RTCCValue=>%2x\n\r",get_rtcc());

printf("%2u %X %4X\n\r",x,y,z);

printf(LCD_PUTC, "n=%u",n);





發表於: 2006/10/27 16:36
頂部


Re: about printf and ccs-c
#10
新會員
新會員


我知道是在終端機,但是我是指输出到屏幕,我在哪个窗口可以看到?.......
谢谢你的回复!

發表於: 2006/10/26 13:48
頂部



(1) 2 »



:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------